Results 1 to 4 of 4
  1. #1
    skydivetom is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    1,046

    VBA Update Routine with Varying Processing Times

    Hello experts:

    I'm hopeful I could get some specific ideas/solutions as to why the performance times for 2 different *update routines* vary differently.

    Attached zip file contains 3 DBs... each of them containing the same data but with different VBA code (in module "05_NNSY"). I will summarize each of these 3 below:

    "00 Update Query 14k Records"
    - Upon opening the DB, open form "F01_MainMenu" and click command button "Update Product Tables". Doing so calls function NNSY_Updates.
    - The module's function includes a single "DoCmd.RunSQL" line of code.
    - The processing time for updating all 14,411 takes approximately 2 seconds.

    "01 DoWhile 14k Records -- Not Indexed"
    - Again, open the form "F01_MainMenu" and click on the command button.
    - Now, this VBA routine uses a DoWhile loop (which is preferred over the UPDATE query).
    - Also, in this version the field [MSHP_LEGACY_REPORT_NUMBER] is **not** indexed in tables [tbl_MISHAP] and [tbl_PERSON].
    - Now, in contrast to the DB "00 Update...", the function takes approximately 25 seconds until the update routine has been successfully executed.

    "02 DoWhile 14k Records -- Indexed"
    - This is a copy of the file "01 DoWhile ..."; however, in this version, the field [MSHP_LEGACY_REPORT_NUMBER] has been indexed (Yes | No Duplicates).


    - While an improvement (WRT to processing time) can be noticed, it still takes about 10 seconds to execute the record update routine.

    In summary:
    - Version "00..." takes ~ 2 seconds
    - Version "01..." takes ~ 25 seconds
    - Version "02..." takes ~ 10 seconds

    Here's the desired end-state:
    - I would like to use the DoWhile method (either DB "01" or "02") over the Update (DB "00") method.
    - Ideally though, the processing time in file "02" should be further reduced (e.g., 1 - 2 seconds -- vs. 10 seconds -- for 14k records).

    My question:
    1. Can the DoWhile be modified so that it would lead to an improved processing time? If so, how?
    2. Please keep in mind that all of the 3 versions only update 1 table (tbl_MISHAP) in these 3 example DBs. In actuality though, I may need to update an additional 4 tables (each of them containing also 14k records). How could the inclusion of other tables (e.g., 5 * 14,000 records) NOT degrade the processing times even further?


    Cheers,
    Tom
    Attached Files Attached Files

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Always use Option Explicit as second line in module.

    Use CurrentDB.Execute rather than DoCmd.RunSQL for Action queries and you won't need the Set Warnings commands.

    SQL Update query will almost always be quicker that recordset processing.

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Hi Tom,

    Agree with Orange, update queries would be faster then looping through the recordset. Now there are various ways of running those update statement, have a look at this great article by Colin: http://www.mendipdatasystems.co.uk/s...s-6/4594478795

    I am attaching a tweaked version of the Do While Not (= Do Until ) loop that uses dLookup instead of another recordset, not much of a difference between the two approaches.

    Cheers,
    Vlad
    Attached Files Attached Files
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  4. #4
    skydivetom is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    1,046
    Orange/Vlad:

    Thank you both for the additional info (and modified function, Vlad). Concur the processing time in the NNSY_UPDATE_LK() doesn't differ much compared to the original NNSY_UPDATE function.

    I enjoyed reading Colin's article... thanks for sharing it.

    Cheers,
    Tom

Please reply to this thread with any new information or opinions.

Similar Threads

  1. VBA Update routine not working correctly
    By skydivetom in forum Programming
    Replies: 3
    Last Post: 11-08-2021, 05:06 PM
  2. Replies: 10
    Last Post: 07-13-2021, 10:08 AM
  3. Replies: 6
    Last Post: 07-09-2021, 10:38 AM
  4. Replies: 16
    Last Post: 10-01-2015, 02:50 PM
  5. Replies: 3
    Last Post: 02-09-2011, 07:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums