VBA in MS Access: how to accelerate a loop operation on a recordset












2















In a database under my maintenance (MS Access 2010) I use a VBA procedure for cleaning up records, concretely: setting values in a field from "yes" to "no". The procedure loops through all records and sets the values in the respective field as required.



My database has about 900 records so far. Not too many, one should think.



My problem: the VBA procedure operates very slowly. On my current machine I have to wait for about 10 seconds until the loop has gone through the 900 records. That's impractical in everyday work.



What I need: I am looking for ways to speed this up, either through improvements to the code, or through a completely different approach.



Here is my procedure:



Private Sub WipeSelectionMarks_Click()

'Remove any filter that might be set to reduce the number of records in
'the form - We want here to operate on all records in the database!

Me.Filter = ""
Me.FilterOn = False
'Don't know if we really need two commands here; but at least it works

'Operate on a recordset that holds all the records displayed in the form
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
rs.MoveFirst
Do Until rs.EOF
With rs
.Edit
!Int_IwSelectMove = False
.Update
End With
rs.MoveNext
Loop

'Message box with info what has been done
MsgBox "A total of " & rs.RecordCount & " records were updated by wiping the Move mark"

'Cleaning up
Set rs = Nothing
Me.Refresh

End Sub


Note 1: if a solution would be using an SQL command instead, I will be grateful for practical hints or examples. I use SQL commands at many places, still, getting put on the right track here would be helpful.



Note 2: Or can the VBA procedure be rewritten in a way that only records where the field in question has value "yes" are processed (these are usually only 20-30 of the 900), and those with "no" are left out?










share|improve this question





























    2















    In a database under my maintenance (MS Access 2010) I use a VBA procedure for cleaning up records, concretely: setting values in a field from "yes" to "no". The procedure loops through all records and sets the values in the respective field as required.



    My database has about 900 records so far. Not too many, one should think.



    My problem: the VBA procedure operates very slowly. On my current machine I have to wait for about 10 seconds until the loop has gone through the 900 records. That's impractical in everyday work.



    What I need: I am looking for ways to speed this up, either through improvements to the code, or through a completely different approach.



    Here is my procedure:



    Private Sub WipeSelectionMarks_Click()

    'Remove any filter that might be set to reduce the number of records in
    'the form - We want here to operate on all records in the database!

    Me.Filter = ""
    Me.FilterOn = False
    'Don't know if we really need two commands here; but at least it works

    'Operate on a recordset that holds all the records displayed in the form
    Dim rs As DAO.Recordset
    Set rs = Me.RecordsetClone
    rs.MoveFirst
    Do Until rs.EOF
    With rs
    .Edit
    !Int_IwSelectMove = False
    .Update
    End With
    rs.MoveNext
    Loop

    'Message box with info what has been done
    MsgBox "A total of " & rs.RecordCount & " records were updated by wiping the Move mark"

    'Cleaning up
    Set rs = Nothing
    Me.Refresh

    End Sub


    Note 1: if a solution would be using an SQL command instead, I will be grateful for practical hints or examples. I use SQL commands at many places, still, getting put on the right track here would be helpful.



    Note 2: Or can the VBA procedure be rewritten in a way that only records where the field in question has value "yes" are processed (these are usually only 20-30 of the 900), and those with "no" are left out?










    share|improve this question



























      2












      2








      2








      In a database under my maintenance (MS Access 2010) I use a VBA procedure for cleaning up records, concretely: setting values in a field from "yes" to "no". The procedure loops through all records and sets the values in the respective field as required.



      My database has about 900 records so far. Not too many, one should think.



      My problem: the VBA procedure operates very slowly. On my current machine I have to wait for about 10 seconds until the loop has gone through the 900 records. That's impractical in everyday work.



      What I need: I am looking for ways to speed this up, either through improvements to the code, or through a completely different approach.



      Here is my procedure:



      Private Sub WipeSelectionMarks_Click()

      'Remove any filter that might be set to reduce the number of records in
      'the form - We want here to operate on all records in the database!

      Me.Filter = ""
      Me.FilterOn = False
      'Don't know if we really need two commands here; but at least it works

      'Operate on a recordset that holds all the records displayed in the form
      Dim rs As DAO.Recordset
      Set rs = Me.RecordsetClone
      rs.MoveFirst
      Do Until rs.EOF
      With rs
      .Edit
      !Int_IwSelectMove = False
      .Update
      End With
      rs.MoveNext
      Loop

      'Message box with info what has been done
      MsgBox "A total of " & rs.RecordCount & " records were updated by wiping the Move mark"

      'Cleaning up
      Set rs = Nothing
      Me.Refresh

      End Sub


      Note 1: if a solution would be using an SQL command instead, I will be grateful for practical hints or examples. I use SQL commands at many places, still, getting put on the right track here would be helpful.



      Note 2: Or can the VBA procedure be rewritten in a way that only records where the field in question has value "yes" are processed (these are usually only 20-30 of the 900), and those with "no" are left out?










      share|improve this question
















      In a database under my maintenance (MS Access 2010) I use a VBA procedure for cleaning up records, concretely: setting values in a field from "yes" to "no". The procedure loops through all records and sets the values in the respective field as required.



      My database has about 900 records so far. Not too many, one should think.



      My problem: the VBA procedure operates very slowly. On my current machine I have to wait for about 10 seconds until the loop has gone through the 900 records. That's impractical in everyday work.



      What I need: I am looking for ways to speed this up, either through improvements to the code, or through a completely different approach.



      Here is my procedure:



      Private Sub WipeSelectionMarks_Click()

      'Remove any filter that might be set to reduce the number of records in
      'the form - We want here to operate on all records in the database!

      Me.Filter = ""
      Me.FilterOn = False
      'Don't know if we really need two commands here; but at least it works

      'Operate on a recordset that holds all the records displayed in the form
      Dim rs As DAO.Recordset
      Set rs = Me.RecordsetClone
      rs.MoveFirst
      Do Until rs.EOF
      With rs
      .Edit
      !Int_IwSelectMove = False
      .Update
      End With
      rs.MoveNext
      Loop

      'Message box with info what has been done
      MsgBox "A total of " & rs.RecordCount & " records were updated by wiping the Move mark"

      'Cleaning up
      Set rs = Nothing
      Me.Refresh

      End Sub


      Note 1: if a solution would be using an SQL command instead, I will be grateful for practical hints or examples. I use SQL commands at many places, still, getting put on the right track here would be helpful.



      Note 2: Or can the VBA procedure be rewritten in a way that only records where the field in question has value "yes" are processed (these are usually only 20-30 of the 900), and those with "no" are left out?







      vba performance ms-access






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 23 '18 at 23:13







      Christian Geiselmann

















      asked Nov 23 '18 at 0:54









      Christian GeiselmannChristian Geiselmann

      3082313




      3082313
























          2 Answers
          2






          active

          oldest

          votes


















          1














          You can use the UPDATE command:



          CurrentDb.Execute "UPDATE YourTable SET Int_IwSelectMove = False"





          share|improve this answer
























          • Thank you! I knew that my solution was unnecessarily complicated...

            – Christian Geiselmann
            Nov 23 '18 at 1:38











          • @ChristianGeiselmann just a reminder, the SQL will update the whole table. If you only want to update the rows with value 'YES' then just add a where clause (e.g. CurrentDb.Execute "UPDATE YourTable SET Int_IwSelectMove = False WHERE Int_IwSelectMove = False")

            – mdialogo
            Nov 23 '18 at 1:44






          • 1





            I tried Me.Refresh, and it did the job. - But I will give Requery also a try, just to test it. Thanks & cheers.

            – Christian Geiselmann
            Nov 23 '18 at 2:07






          • 1





            Yes, the pencil is the problem. And, yes, I tried right now exactly this: created a button btnFocustaker and tried to use SetFocus on it; strangely: no effect; then tried with a field instead (fldFocustaker), again no effect. - But this is now already a completely different problem than the one mentioned in the initial question. I will do some experiments. If I do not find a solution I will perhaps address this in a separate question. Thank you for your help!

            – Christian Geiselmann
            Nov 23 '18 at 2:29








          • 2





            @ChristianGeiselmann try to use Me.Dirty = False to save edits from form to database before run your update comands

            – 4dmonster
            Nov 23 '18 at 5:57



















          2















          can the VBA procedure be rewritten in a way that only records where
          the field in question has value "yes" are processed




          Indeed, and that may very well be the fastest method, as you will not have to requery the form:



             With rs
          Do Until .EOF
          If !Int_IwSelectMove.Value = True Then
          .Edit
          !Int_IwSelectMove = False
          .Update
          End If
          .MoveNext
          Loop
          .Close
          End With


          Or you could use FindFirst or a filtered recordset. Running SQL on the recordset of a form is usually the last option.






          share|improve this answer
























          • Thank you for elaborating on this second idea to solve the issue. Very helpful! Although the SQL approach (see other answer to this question) already works for me, I will give this improved VBA code a try and see what is the gain of speed. I will report back then.

            – Christian Geiselmann
            Nov 23 '18 at 12:31








          • 1





            Report after testing: Simply: Wow! This makes the processing absolutely instantaneous! Phantastic improvement to my initial code!

            – Christian Geiselmann
            Nov 23 '18 at 19:56













          • Yeps. Operating the RecordsetClone is very fast.

            – Gustav
            Nov 23 '18 at 20:54











          • One question: why is running SQL on the recordset of a form usually the last option? Any problems related to that approach?

            – Christian Geiselmann
            Nov 23 '18 at 23:11








          • 1





            Because the RecordsetClone is already there, cached, and any update is reflected in the form at once. Running a new outside query has to, once again, retrieve records, and modifications cannot be expected to be seen in the form until a requery - which will once again retrieve the same records - and the current record is moved, and you may have to set it back using BookMark.

            – Gustav
            Nov 24 '18 at 8:41











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439512%2fvba-in-ms-access-how-to-accelerate-a-loop-operation-on-a-recordset%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You can use the UPDATE command:



          CurrentDb.Execute "UPDATE YourTable SET Int_IwSelectMove = False"





          share|improve this answer
























          • Thank you! I knew that my solution was unnecessarily complicated...

            – Christian Geiselmann
            Nov 23 '18 at 1:38











          • @ChristianGeiselmann just a reminder, the SQL will update the whole table. If you only want to update the rows with value 'YES' then just add a where clause (e.g. CurrentDb.Execute "UPDATE YourTable SET Int_IwSelectMove = False WHERE Int_IwSelectMove = False")

            – mdialogo
            Nov 23 '18 at 1:44






          • 1





            I tried Me.Refresh, and it did the job. - But I will give Requery also a try, just to test it. Thanks & cheers.

            – Christian Geiselmann
            Nov 23 '18 at 2:07






          • 1





            Yes, the pencil is the problem. And, yes, I tried right now exactly this: created a button btnFocustaker and tried to use SetFocus on it; strangely: no effect; then tried with a field instead (fldFocustaker), again no effect. - But this is now already a completely different problem than the one mentioned in the initial question. I will do some experiments. If I do not find a solution I will perhaps address this in a separate question. Thank you for your help!

            – Christian Geiselmann
            Nov 23 '18 at 2:29








          • 2





            @ChristianGeiselmann try to use Me.Dirty = False to save edits from form to database before run your update comands

            – 4dmonster
            Nov 23 '18 at 5:57
















          1














          You can use the UPDATE command:



          CurrentDb.Execute "UPDATE YourTable SET Int_IwSelectMove = False"





          share|improve this answer
























          • Thank you! I knew that my solution was unnecessarily complicated...

            – Christian Geiselmann
            Nov 23 '18 at 1:38











          • @ChristianGeiselmann just a reminder, the SQL will update the whole table. If you only want to update the rows with value 'YES' then just add a where clause (e.g. CurrentDb.Execute "UPDATE YourTable SET Int_IwSelectMove = False WHERE Int_IwSelectMove = False")

            – mdialogo
            Nov 23 '18 at 1:44






          • 1





            I tried Me.Refresh, and it did the job. - But I will give Requery also a try, just to test it. Thanks & cheers.

            – Christian Geiselmann
            Nov 23 '18 at 2:07






          • 1





            Yes, the pencil is the problem. And, yes, I tried right now exactly this: created a button btnFocustaker and tried to use SetFocus on it; strangely: no effect; then tried with a field instead (fldFocustaker), again no effect. - But this is now already a completely different problem than the one mentioned in the initial question. I will do some experiments. If I do not find a solution I will perhaps address this in a separate question. Thank you for your help!

            – Christian Geiselmann
            Nov 23 '18 at 2:29








          • 2





            @ChristianGeiselmann try to use Me.Dirty = False to save edits from form to database before run your update comands

            – 4dmonster
            Nov 23 '18 at 5:57














          1












          1








          1







          You can use the UPDATE command:



          CurrentDb.Execute "UPDATE YourTable SET Int_IwSelectMove = False"





          share|improve this answer













          You can use the UPDATE command:



          CurrentDb.Execute "UPDATE YourTable SET Int_IwSelectMove = False"






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 23 '18 at 1:27









          mdialogomdialogo

          423513




          423513













          • Thank you! I knew that my solution was unnecessarily complicated...

            – Christian Geiselmann
            Nov 23 '18 at 1:38











          • @ChristianGeiselmann just a reminder, the SQL will update the whole table. If you only want to update the rows with value 'YES' then just add a where clause (e.g. CurrentDb.Execute "UPDATE YourTable SET Int_IwSelectMove = False WHERE Int_IwSelectMove = False")

            – mdialogo
            Nov 23 '18 at 1:44






          • 1





            I tried Me.Refresh, and it did the job. - But I will give Requery also a try, just to test it. Thanks & cheers.

            – Christian Geiselmann
            Nov 23 '18 at 2:07






          • 1





            Yes, the pencil is the problem. And, yes, I tried right now exactly this: created a button btnFocustaker and tried to use SetFocus on it; strangely: no effect; then tried with a field instead (fldFocustaker), again no effect. - But this is now already a completely different problem than the one mentioned in the initial question. I will do some experiments. If I do not find a solution I will perhaps address this in a separate question. Thank you for your help!

            – Christian Geiselmann
            Nov 23 '18 at 2:29








          • 2





            @ChristianGeiselmann try to use Me.Dirty = False to save edits from form to database before run your update comands

            – 4dmonster
            Nov 23 '18 at 5:57



















          • Thank you! I knew that my solution was unnecessarily complicated...

            – Christian Geiselmann
            Nov 23 '18 at 1:38











          • @ChristianGeiselmann just a reminder, the SQL will update the whole table. If you only want to update the rows with value 'YES' then just add a where clause (e.g. CurrentDb.Execute "UPDATE YourTable SET Int_IwSelectMove = False WHERE Int_IwSelectMove = False")

            – mdialogo
            Nov 23 '18 at 1:44






          • 1





            I tried Me.Refresh, and it did the job. - But I will give Requery also a try, just to test it. Thanks & cheers.

            – Christian Geiselmann
            Nov 23 '18 at 2:07






          • 1





            Yes, the pencil is the problem. And, yes, I tried right now exactly this: created a button btnFocustaker and tried to use SetFocus on it; strangely: no effect; then tried with a field instead (fldFocustaker), again no effect. - But this is now already a completely different problem than the one mentioned in the initial question. I will do some experiments. If I do not find a solution I will perhaps address this in a separate question. Thank you for your help!

            – Christian Geiselmann
            Nov 23 '18 at 2:29








          • 2





            @ChristianGeiselmann try to use Me.Dirty = False to save edits from form to database before run your update comands

            – 4dmonster
            Nov 23 '18 at 5:57

















          Thank you! I knew that my solution was unnecessarily complicated...

          – Christian Geiselmann
          Nov 23 '18 at 1:38





          Thank you! I knew that my solution was unnecessarily complicated...

          – Christian Geiselmann
          Nov 23 '18 at 1:38













          @ChristianGeiselmann just a reminder, the SQL will update the whole table. If you only want to update the rows with value 'YES' then just add a where clause (e.g. CurrentDb.Execute "UPDATE YourTable SET Int_IwSelectMove = False WHERE Int_IwSelectMove = False")

          – mdialogo
          Nov 23 '18 at 1:44





          @ChristianGeiselmann just a reminder, the SQL will update the whole table. If you only want to update the rows with value 'YES' then just add a where clause (e.g. CurrentDb.Execute "UPDATE YourTable SET Int_IwSelectMove = False WHERE Int_IwSelectMove = False")

          – mdialogo
          Nov 23 '18 at 1:44




          1




          1





          I tried Me.Refresh, and it did the job. - But I will give Requery also a try, just to test it. Thanks & cheers.

          – Christian Geiselmann
          Nov 23 '18 at 2:07





          I tried Me.Refresh, and it did the job. - But I will give Requery also a try, just to test it. Thanks & cheers.

          – Christian Geiselmann
          Nov 23 '18 at 2:07




          1




          1





          Yes, the pencil is the problem. And, yes, I tried right now exactly this: created a button btnFocustaker and tried to use SetFocus on it; strangely: no effect; then tried with a field instead (fldFocustaker), again no effect. - But this is now already a completely different problem than the one mentioned in the initial question. I will do some experiments. If I do not find a solution I will perhaps address this in a separate question. Thank you for your help!

          – Christian Geiselmann
          Nov 23 '18 at 2:29







          Yes, the pencil is the problem. And, yes, I tried right now exactly this: created a button btnFocustaker and tried to use SetFocus on it; strangely: no effect; then tried with a field instead (fldFocustaker), again no effect. - But this is now already a completely different problem than the one mentioned in the initial question. I will do some experiments. If I do not find a solution I will perhaps address this in a separate question. Thank you for your help!

          – Christian Geiselmann
          Nov 23 '18 at 2:29






          2




          2





          @ChristianGeiselmann try to use Me.Dirty = False to save edits from form to database before run your update comands

          – 4dmonster
          Nov 23 '18 at 5:57





          @ChristianGeiselmann try to use Me.Dirty = False to save edits from form to database before run your update comands

          – 4dmonster
          Nov 23 '18 at 5:57













          2















          can the VBA procedure be rewritten in a way that only records where
          the field in question has value "yes" are processed




          Indeed, and that may very well be the fastest method, as you will not have to requery the form:



             With rs
          Do Until .EOF
          If !Int_IwSelectMove.Value = True Then
          .Edit
          !Int_IwSelectMove = False
          .Update
          End If
          .MoveNext
          Loop
          .Close
          End With


          Or you could use FindFirst or a filtered recordset. Running SQL on the recordset of a form is usually the last option.






          share|improve this answer
























          • Thank you for elaborating on this second idea to solve the issue. Very helpful! Although the SQL approach (see other answer to this question) already works for me, I will give this improved VBA code a try and see what is the gain of speed. I will report back then.

            – Christian Geiselmann
            Nov 23 '18 at 12:31








          • 1





            Report after testing: Simply: Wow! This makes the processing absolutely instantaneous! Phantastic improvement to my initial code!

            – Christian Geiselmann
            Nov 23 '18 at 19:56













          • Yeps. Operating the RecordsetClone is very fast.

            – Gustav
            Nov 23 '18 at 20:54











          • One question: why is running SQL on the recordset of a form usually the last option? Any problems related to that approach?

            – Christian Geiselmann
            Nov 23 '18 at 23:11








          • 1





            Because the RecordsetClone is already there, cached, and any update is reflected in the form at once. Running a new outside query has to, once again, retrieve records, and modifications cannot be expected to be seen in the form until a requery - which will once again retrieve the same records - and the current record is moved, and you may have to set it back using BookMark.

            – Gustav
            Nov 24 '18 at 8:41
















          2















          can the VBA procedure be rewritten in a way that only records where
          the field in question has value "yes" are processed




          Indeed, and that may very well be the fastest method, as you will not have to requery the form:



             With rs
          Do Until .EOF
          If !Int_IwSelectMove.Value = True Then
          .Edit
          !Int_IwSelectMove = False
          .Update
          End If
          .MoveNext
          Loop
          .Close
          End With


          Or you could use FindFirst or a filtered recordset. Running SQL on the recordset of a form is usually the last option.






          share|improve this answer
























          • Thank you for elaborating on this second idea to solve the issue. Very helpful! Although the SQL approach (see other answer to this question) already works for me, I will give this improved VBA code a try and see what is the gain of speed. I will report back then.

            – Christian Geiselmann
            Nov 23 '18 at 12:31








          • 1





            Report after testing: Simply: Wow! This makes the processing absolutely instantaneous! Phantastic improvement to my initial code!

            – Christian Geiselmann
            Nov 23 '18 at 19:56













          • Yeps. Operating the RecordsetClone is very fast.

            – Gustav
            Nov 23 '18 at 20:54











          • One question: why is running SQL on the recordset of a form usually the last option? Any problems related to that approach?

            – Christian Geiselmann
            Nov 23 '18 at 23:11








          • 1





            Because the RecordsetClone is already there, cached, and any update is reflected in the form at once. Running a new outside query has to, once again, retrieve records, and modifications cannot be expected to be seen in the form until a requery - which will once again retrieve the same records - and the current record is moved, and you may have to set it back using BookMark.

            – Gustav
            Nov 24 '18 at 8:41














          2












          2








          2








          can the VBA procedure be rewritten in a way that only records where
          the field in question has value "yes" are processed




          Indeed, and that may very well be the fastest method, as you will not have to requery the form:



             With rs
          Do Until .EOF
          If !Int_IwSelectMove.Value = True Then
          .Edit
          !Int_IwSelectMove = False
          .Update
          End If
          .MoveNext
          Loop
          .Close
          End With


          Or you could use FindFirst or a filtered recordset. Running SQL on the recordset of a form is usually the last option.






          share|improve this answer














          can the VBA procedure be rewritten in a way that only records where
          the field in question has value "yes" are processed




          Indeed, and that may very well be the fastest method, as you will not have to requery the form:



             With rs
          Do Until .EOF
          If !Int_IwSelectMove.Value = True Then
          .Edit
          !Int_IwSelectMove = False
          .Update
          End If
          .MoveNext
          Loop
          .Close
          End With


          Or you could use FindFirst or a filtered recordset. Running SQL on the recordset of a form is usually the last option.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 23 '18 at 7:40









          GustavGustav

          30.4k52037




          30.4k52037













          • Thank you for elaborating on this second idea to solve the issue. Very helpful! Although the SQL approach (see other answer to this question) already works for me, I will give this improved VBA code a try and see what is the gain of speed. I will report back then.

            – Christian Geiselmann
            Nov 23 '18 at 12:31








          • 1





            Report after testing: Simply: Wow! This makes the processing absolutely instantaneous! Phantastic improvement to my initial code!

            – Christian Geiselmann
            Nov 23 '18 at 19:56













          • Yeps. Operating the RecordsetClone is very fast.

            – Gustav
            Nov 23 '18 at 20:54











          • One question: why is running SQL on the recordset of a form usually the last option? Any problems related to that approach?

            – Christian Geiselmann
            Nov 23 '18 at 23:11








          • 1





            Because the RecordsetClone is already there, cached, and any update is reflected in the form at once. Running a new outside query has to, once again, retrieve records, and modifications cannot be expected to be seen in the form until a requery - which will once again retrieve the same records - and the current record is moved, and you may have to set it back using BookMark.

            – Gustav
            Nov 24 '18 at 8:41



















          • Thank you for elaborating on this second idea to solve the issue. Very helpful! Although the SQL approach (see other answer to this question) already works for me, I will give this improved VBA code a try and see what is the gain of speed. I will report back then.

            – Christian Geiselmann
            Nov 23 '18 at 12:31








          • 1





            Report after testing: Simply: Wow! This makes the processing absolutely instantaneous! Phantastic improvement to my initial code!

            – Christian Geiselmann
            Nov 23 '18 at 19:56













          • Yeps. Operating the RecordsetClone is very fast.

            – Gustav
            Nov 23 '18 at 20:54











          • One question: why is running SQL on the recordset of a form usually the last option? Any problems related to that approach?

            – Christian Geiselmann
            Nov 23 '18 at 23:11








          • 1





            Because the RecordsetClone is already there, cached, and any update is reflected in the form at once. Running a new outside query has to, once again, retrieve records, and modifications cannot be expected to be seen in the form until a requery - which will once again retrieve the same records - and the current record is moved, and you may have to set it back using BookMark.

            – Gustav
            Nov 24 '18 at 8:41

















          Thank you for elaborating on this second idea to solve the issue. Very helpful! Although the SQL approach (see other answer to this question) already works for me, I will give this improved VBA code a try and see what is the gain of speed. I will report back then.

          – Christian Geiselmann
          Nov 23 '18 at 12:31







          Thank you for elaborating on this second idea to solve the issue. Very helpful! Although the SQL approach (see other answer to this question) already works for me, I will give this improved VBA code a try and see what is the gain of speed. I will report back then.

          – Christian Geiselmann
          Nov 23 '18 at 12:31






          1




          1





          Report after testing: Simply: Wow! This makes the processing absolutely instantaneous! Phantastic improvement to my initial code!

          – Christian Geiselmann
          Nov 23 '18 at 19:56







          Report after testing: Simply: Wow! This makes the processing absolutely instantaneous! Phantastic improvement to my initial code!

          – Christian Geiselmann
          Nov 23 '18 at 19:56















          Yeps. Operating the RecordsetClone is very fast.

          – Gustav
          Nov 23 '18 at 20:54





          Yeps. Operating the RecordsetClone is very fast.

          – Gustav
          Nov 23 '18 at 20:54













          One question: why is running SQL on the recordset of a form usually the last option? Any problems related to that approach?

          – Christian Geiselmann
          Nov 23 '18 at 23:11







          One question: why is running SQL on the recordset of a form usually the last option? Any problems related to that approach?

          – Christian Geiselmann
          Nov 23 '18 at 23:11






          1




          1





          Because the RecordsetClone is already there, cached, and any update is reflected in the form at once. Running a new outside query has to, once again, retrieve records, and modifications cannot be expected to be seen in the form until a requery - which will once again retrieve the same records - and the current record is moved, and you may have to set it back using BookMark.

          – Gustav
          Nov 24 '18 at 8:41





          Because the RecordsetClone is already there, cached, and any update is reflected in the form at once. Running a new outside query has to, once again, retrieve records, and modifications cannot be expected to be seen in the form until a requery - which will once again retrieve the same records - and the current record is moved, and you may have to set it back using BookMark.

          – Gustav
          Nov 24 '18 at 8:41


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439512%2fvba-in-ms-access-how-to-accelerate-a-loop-operation-on-a-recordset%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown