Results 1 to 4 of 4
  1. #1
    Rich30005 is offline Novice
    Windows 10 Office 365
    Join Date
    Jul 2022
    Posts
    1

    AddNew method extremely slow for first record added only

    I have a split database, multi user, Access application (Windows 10 -- Access 64-bit version Office 365).
    A particular form where I give users the ability to add a record to the database is unbound. aA user enters all the data in the fields provided on the form, clicks "Add Record". I then run an extensive set of editing checks, then I open a recordset object and use the AddNew method to add the record to a single table that has only one index for an AutoNumber field. Everything works fine, but the first record the user adds can take an annoyingly long time -- like 45 seconds to a minute. Some have reported longer wait times. If the form is kept open and the user enters more records, subsequent added records typically take a second or so at most. To experiment, I executed all the editing checks and added nothing -- those checks take almost no time. I then eliminated all the editing checks and just go directly to add the record -- in that scenario, the first record takes a lot of time and subsequent records happen very fast.
    I tried to make the form bound to the underlying table -- I dislike that approach but found pretty much the same pattern. I also tried using VBA to simply construct an INSERT SQL statement (that is, do not user DAO to open a recordset) and got the same annoying result. It seems no matter what I do, that first record takes an annoyingly long time.
    If I exit Access altogether so that nothing is cached and open the application again, I can reproduce this result over and over, although on occasion, the first record gets added somewhat faster than described above -- I just cant explain that variation for the first record added.
    All idea would be very welcome/
    TIA
    Rich

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,938
    It is normal to maintain a connection open to the be all the time?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    It is probably the overhead of constantly opening a connection

    unbound forms will always be slower because on this - you are avoiding using one of the main benefits of access.

    You haven’t said but I presume with your split database each user has their own copy of the front end - in which case are all users experiencing the same issue?

    have you tried compact repair and decompiling

    Also is your table properly indexed?

  4. #4
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    Have you considered a querydef? No need to open a recordset.

    something like
    Code:
    Const Sql_Insert As String = _ 
              "Insert into tblPeople" & _ 
              "(FirstName,MiddleName,LastName,Suffix) " & _ 
              "Values(p0,p1,p2,p3)"
    
    
         With CurrentDb.CreateQueryDef("", SQL_Insert)
              .Parameters(0) = Me.FirstName
              .Parameters(1) = Me.MiddleName
              .Parameters(2) = Me.LastName
              .Parameters(3) = Me.Suffix
         .Execute dbFailOnError
         .Close
    End With
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

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

Similar Threads

  1. Network being extremely slow
    By perryc in forum Forms
    Replies: 6
    Last Post: 02-04-2022, 10:14 AM
  2. Replies: 3
    Last Post: 07-26-2017, 08:14 AM
  3. Connecting to SQL Server from Windows 7 extremely slow
    By justinmregan87 in forum SQL Server
    Replies: 1
    Last Post: 07-22-2015, 12:59 PM
  4. Query Runs Extremely Slow
    By eagerlearner in forum Queries
    Replies: 1
    Last Post: 10-30-2014, 06:44 AM
  5. Date() in query runs extremely slow on Windows 7
    By TagYoureIt in forum Access
    Replies: 4
    Last Post: 03-20-2013, 01:24 PM

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