Hello all,
When I run a piece of SQL in a query from the access query design view, I get 2 records appear, as I would expect.
When I try and run the same thing as a recordset in VBA, I don't get any records.
I can't for the life of me figure (or find) out why.
The code (including the SQL) is as below - can anyone see what is wrong?
When I run a piece of SQL in a query from the access query design view, I get 2 records appear, as I would expect.
When I try and run the same thing as a recordset in VBA, I don't get any records.
I can't for the life of me figure (or find) out why.
The code (including the SQL) is as below - can anyone see what is wrong?
Code:
Dim dteSFDeliveryDate As Date
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL
Dim strFiles
dteSFDeliveryDate = OpenArgs
DoCmd.RunCommand acCmdSaveRecord
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryUpdateBoxItemOrderID"
DoCmd.SetWarnings True
strSQL = "SELECT Description, Surname, Forename, BoxItemID, tblBoxItem.OrderID, TempSelect From tblBoxItem, qryTodaysOrder WHERE TempSelect=-1;"
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL)
MsgBox rs.RecordCount
rs.MoveLast
rs.MoveFirst
Do Until rs.EOF
strFiles = strFiles & vbCrLf & rs.Fields("description").Value & " (" & rs.Fields("surname").Value & ", " & rs.Fields("forename").Value & ")"
rs.MoveNext
Loop
MsgBox "Box requested successfully." & vbCrLf & vbCrLf & "Delivery Expected: " & dteSFDeliveryDate, vbInformation + vbOKOnly, "Box Request"
DoCmd.Close acForm, "frmSelectFiles"
Forms!frmbox!BoxLocation.Requery
Forms!frmbox.Visible = True
rs.Close
Last edited: