Results 1 to 3 of 3
  1. #1
    fluffyvampirekitten is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    108

    ADOB - Update runs very slow

    I'm doing an update table using vba - ADODB connection

    But it runs too slow
    Is there any other way to do an update



    Code:
    Option Compare Database
    Option Explicit
    Sub main()
    Dim objRecordset As ADODB.Recordset
    Set objRecordset = New ADODB.Recordset
    'initated recordset object
    objRecordset.ActiveConnection = CurrentProject.Connection
    Call objRecordset.Open("IntraSystemData", , , adLockBatchOptimistic)
    End Sub
    Sub Update_INS()
    Dim objRecordset As ADODB.Recordset
    Set objRecordset = New ADODB.Recordset
    Dim i As Integer
    Dim value As Variant
    
    'initated recordset obejct
    objRecordset.ActiveConnection = CurrentProject.Connection
     Call objRecordset.Open("IntraSystemData", , , adLockBatchOptimistic)
     
    DBEngine.SetOption dbMaxLocksPerFile, 50000
     
     ' Find no_of_ins_v for each record
     Do Until objRecordset.EOF
                
        If objRecordset("NO_INS").value = 0 Then
            objRecordset("INSTITUTION") = "P-NHGP"
            objRecordset.UpdateBatch
        Else
            DoCmd.RunSQL "Update IntraSystemData INNER JOIN IntraSystem_INS ON [IntraSystemData].[GROUP_NO] = [IntraSystem_INS].[GROUP_NO]" & _
            "SET [IntraSystemData].[INSTITUTION]  = [IntraSystem_INS].[FV_INS]" & _
            "WHERE [IntraSystemData].[GROUP_NO]  = [IntraSystem_INS].[GROUP_NO]"
                           
        End If
        objRecordset.MoveNext
    Loop
            
        objRecordset.Close
        Set objRecordset = Nothing
        
    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Why are you using ADO and code?
    Just use an access query, its faster.



    Quote Originally Posted by fluffyvampirekitten View Post
    I'm doing an update table using vba - ADODB connection

    But it runs too slow
    Is there any other way to do an update

    Code:
    Option Compare Database
    Option Explicit
    Sub main()
    Dim objRecordset As ADODB.Recordset
    Set objRecordset = New ADODB.Recordset
    'initated recordset object
    objRecordset.ActiveConnection = CurrentProject.Connection
    Call objRecordset.Open("IntraSystemData", , , adLockBatchOptimistic)
    End Sub
    Sub Update_INS()
    Dim objRecordset As ADODB.Recordset
    Set objRecordset = New ADODB.Recordset
    Dim i As Integer
    Dim value As Variant
    
    'initated recordset obejct
    objRecordset.ActiveConnection = CurrentProject.Connection
     Call objRecordset.Open("IntraSystemData", , , adLockBatchOptimistic)
     
    DBEngine.SetOption dbMaxLocksPerFile, 50000
     
     ' Find no_of_ins_v for each record
     Do Until objRecordset.EOF
                
        If objRecordset("NO_INS").value = 0 Then
            objRecordset("INSTITUTION") = "P-NHGP"
            objRecordset.UpdateBatch
        Else
            DoCmd.RunSQL "Update IntraSystemData INNER JOIN IntraSystem_INS ON [IntraSystemData].[GROUP_NO] = [IntraSystem_INS].[GROUP_NO]" & _
            "SET [IntraSystemData].[INSTITUTION]  = [IntraSystem_INS].[FV_INS]" & _
            "WHERE [IntraSystemData].[GROUP_NO]  = [IntraSystem_INS].[GROUP_NO]"
                           
        End If
        objRecordset.MoveNext
    Loop
            
        objRecordset.Close
        Set objRecordset = Nothing
        
    End Sub

  3. #3
    fluffyvampirekitten is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    108
    Okay , Ill try use an access query instead. Thank you

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

Similar Threads

  1. Query Runs Extremely Slow
    By eagerlearner in forum Queries
    Replies: 1
    Last Post: 10-30-2014, 06:44 AM
  2. Update queries sometimes very slow
    By GregL65R in forum Programming
    Replies: 3
    Last Post: 12-05-2013, 05:42 PM
  3. Date() in query runs extremely slow on Windows 7
    By TagYoureIt in forum Access
    Replies: 4
    Last Post: 03-20-2013, 01:24 PM
  4. Replies: 2
    Last Post: 11-19-2012, 03:23 AM
  5. Replies: 1
    Last Post: 01-22-2011, 12:23 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