We help IT Professionals succeed at work.
Get Started

VBA Bombs Error 3052 Updating Record Set

UWW_Jax
UWW_Jax asked
on
515 Views
Last Modified: 2012-05-12
How can I get the code to run faster and run with out bombing.  I have over 1 million records, database is 1.28 gig.


Function UpdateCumuMissing()

'On Error GoTo Error123

Dim db As DAO.Database
Dim rs, Rst As DAO.Recordset
Dim Matchkey As String
Dim i, j, k As Integer
Dim Monthkey As String
Dim txtyyyyMM As String

'i = 0
  Set db = CurrentDb
  Set rs = db.OpenRecordset("Qry_UP_MissingIxosCertReview", dbOpenDynaset)
  

    rs.MoveFirst
    Matchkey = rs!sys_cust_St
    txtyyyyMM = Format(rs!yyyymm, "@@@@_@@")
    'Monthkey = ReviewCertKey(txtyyyyMM, Matchkey)
    
While Not rs.EOF
  'i = i + 1
  
  'Select Case i
  'Case Is = 10000, 50000, 100000, 200000, 300000, 500000
  'MsgBox i / rs.RecordCount & "    " & i
  'End Select
  
  
    Set Rst = db.OpenRecordset("SELECT [" & txtyyyyMM & "] As Expr1 FROM tbl_Customer_Certs WHERE (Sys_cust_st ='" & Matchkey & "')")
    
    Monthkey = Rst!Expr1
    'SELECT [" & Txtyyymm & "]* FROM tbl_Customer_Certs WHERE (Sys_cust_st ='" & matchkey & "')")
  
  
  'rs.Update
  rs.Edit
  rs!IxosCertDateMatch = Monthkey
  'rs!AnotherField = SomeOtherValue
  rs.Update
  rs.MoveNext
  Set Rst = Nothing
Wend
  Set rs = Nothing
  Set db = Nothing
MsgBox "Complete"



MsgBox "Complete"

ErrorExit:
    Exit Function
Error123:
    Set Rst = Nothing
    Set rs = Nothing
    Set db = Nothing
    MsgBox Err.Description & vbNewLine & Err.Number & vbNewLine & Err.Source
Resume ErrorExit


End Function

Open in new window

Comment
Watch Question
Sr Tax Accountant
Commented:
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE