Results 1 to 3 of 3
  1. #1
    Tyork is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Oct 2010
    Posts
    35

    Batch Update

    I've created a task scheduler and based on certain conditions tasks will be scheduled into a database. Below is a sample which basically adds a task occurrence every weekday for 2500 iterations which turns out to be approx 7 years.

    Code:
     
        Case 3
    
            For x = 0 To 2499
            
            Day = sd + x
            
            DayOfWeek = Weekday(Day)
                            
                If DayOfWeek = 2 Or DayOfWeek = 3 Or DayOfWeek = 4 Or DayOfWeek = 5 Or DayOfWeek = 6 Then
                
                SQLAddOccurrence3 = "INSERT INTO [BMS_OCCURRENCE] (TaskID,TaskName, Day, Owner, Deadline1, Deadline2, Deadline3, Deadline4)" & _
                    "VALUES('" & TaskID & "', '" & TN & "', '" & Day & "', '" & OW & "', '" & d1 & "', '" & d2 & "', '" & d3 & "', '" & d4 & "');"
                
                DoCmd.SetWarnings False
                
                    DoCmd.RunSQL SQLAddOccurrence3
                
                DoCmd.SetWarnings True
            
                End If
            
            Next x
    The code executes properly. The issue is that when I run this locally it executes within 4 seconds. It takes 75 seconds to run this on the network. I had the DBA in my office and he did not provide me any solutions other than to update it as a batch instead of writing to the table at the end of each loop. I'm not sure how to go about a batch update; would anybody be able to help me out? I would appreciate any suggestions or help. Thanks!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    This is not a direct answer to your question, but in my experience a recordset would be much faster. This type of thing, which can be adapted (rsLocal was previously opened on the target table):

    Code:
        With rsLocal
          .AddNew
          !CustomerKey = rst!Cust_Key
          !CustomerName = rst!Name
          .Update
        End With
    That said, I'd offer another thought. Do you really want to add 7 years worth? You know your data better than I do of course, but I have situations where I insert standing reservation data for certain customers. What I do is create an automated process that will insert reservations 2 months out on the first of the month. In other words, on Dec 1 the reservations for Feb will get added. That type of thing wouldn't be hard to set up to insert them a week, month, or whatever ahead.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    KathyL is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    94
    Quote Originally Posted by Tyork View Post
    I've created a task scheduler and based on certain conditions tasks will be scheduled into a database. Below is a sample which basically adds a task occurrence every weekday for 2500 iterations which turns out to be approx 7 years.

    The code executes properly. The issue is that when I run this locally it executes within 4 seconds. It takes 75 seconds to run this on the network. I had the DBA in my office and he did not provide me any solutions other than to update it as a batch instead of writing to the table at the end of each loop. I'm not sure how to go about a batch update; would anybody be able to help me out? I would appreciate any suggestions or help. Thanks!
    In no circumstance should you expect the code to operate at the same speed on a network as it can operate on a stand alone local PC.

    I don't think updating it as a batch would change a thing.

    I also think 75 seconds to be very reasonable. I've got action queries that do something similar off a network and get slower responses than you, and I have to accept it for what it is.

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

Similar Threads

  1. Shell with Batch Variables
    By robbyaube in forum Programming
    Replies: 2
    Last Post: 12-19-2019, 11:06 AM
  2. Replies: 30
    Last Post: 06-26-2011, 10:47 PM
  3. Batch import .txt
    By hchui in forum Import/Export Data
    Replies: 1
    Last Post: 10-14-2010, 08:57 PM
  4. Replies: 5
    Last Post: 01-05-2010, 10:22 PM
  5. New Database - Batch processing
    By stevo2820 in forum Database Design
    Replies: 0
    Last Post: 04-30-2007, 02:22 AM

Tags for this Thread

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