Question : Loop Problems

I am trying to run a query repeatedly, using the criteria [ClaimNumber] from the table tblClaimNumbers.

I've attached my attempt to get started with it.

I am getting a Compile error:
Sub or Function not defined.
On: Set db = tblClaimNumbers()
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
Function UpdateDeductibleTable()
Dim db As DAO.Database
Dim rs1 As DAO.Recordset
Dim rs2 As DAO.Recordset
  
    Set db = tblClaimNumbers()
    Set rs1 = db.OpenRecordset("qry_CalcAmtsforDedRepts")
    Set rs2 = db.OpenRecordset("DeductibleInfoStatic")
  
    rs1.MoveFirst
    Do Until rs1.EOF
        If rs1![ClaimNumber] > 0 Then
            rs2.AddNew
            rs2![ClaimNumber] = rs1![ClaimNumber]
            rs2.Update
        End If
    Loop
  
    RS.Close
    Set RS = Nothing
    Set db = Nothing
  
End Function

Answer : Loop Problems

Hi 4charity,

Try set db=CurrentDB

Gary
Random Solutions  
 
programming4us programming4us