I have a query that I am adding to.. After many attempts of trying to get the openrecordset command working, I am not having this problem: it doesn't for some reason add to the query on the first shot. I need to close the query and run it again and then it works. everytime after that works fine.. but if i close the database down and try it again, it won't work the first time around... here is the code:
Set rst = dbs.OpenRecordset("InvoiceQuery"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
start = InputBox("Please enter a start number", "Access", , 2000, 2000)
If Me.FromDate <> "" And Me.ToDate <> "" Then
DoCmd.SetWarnings False
x = MsgBox("You are about to print invoices, are you sure?", 1)
If x = 1 Then
CurrentDb.QueryDefs("InvoiceQuery"
.SQL = strSQL
Let counter = 1
If (rst.RecordCount <> counter) Or (rst.RecordCount = counter) Then
rst.MoveFirst
rst.Edit
rst!InvoiceNumber = "E" & start
rst.Update
rst.MoveNext
Do Until counter = rst.RecordCount
Let counter = counter + 1
Let start = start + 1
rst.Edit
rst!InvoiceNumber = "E" & start
rst.Update
rst.MoveNext
Loop
End If
DoCmd.OpenQuery "InvoiceQuery"
Else
End If
Else
MsgBox "You MUST enter a date range"
End If
Set rst = Nothing
Set rst = dbs.OpenRecordset("InvoiceQuery"
start = InputBox("Please enter a start number", "Access", , 2000, 2000)
If Me.FromDate <> "" And Me.ToDate <> "" Then
DoCmd.SetWarnings False
x = MsgBox("You are about to print invoices, are you sure?", 1)
If x = 1 Then
CurrentDb.QueryDefs("InvoiceQuery"
Let counter = 1
If (rst.RecordCount <> counter) Or (rst.RecordCount = counter) Then
rst.MoveFirst
rst.Edit
rst!InvoiceNumber = "E" & start
rst.Update
rst.MoveNext
Do Until counter = rst.RecordCount
Let counter = counter + 1
Let start = start + 1
rst.Edit
rst!InvoiceNumber = "E" & start
rst.Update
rst.MoveNext
Loop
End If
DoCmd.OpenQuery "InvoiceQuery"
Else
End If
Else
MsgBox "You MUST enter a date range"
End If
Set rst = Nothing