Here is the code that I have so far:
I don't see what I'm doing wrong - but the error I get is:
Runtime error 3061
Too few paramaters. Expected 1.
I can paste that same SQL string (except putting the value of the variable in) into a regular query in Access and it works just fine.
I don't understand what I'm doing wrong.
All this is supposed to do is export a spreadsheet for a date specified in a form, and before doing the export, notify you if there are no records instead of exporting a sheet with nothing in it.
Help!
Code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim strVar As String
strVar = [Forms]![frmDateSelection3].[QueryDate].[Value]
strSQL = "SELECT * FROM qryCustInfo WHERE ((qryCustInfo.[Date Entered System])=#" & strVar & "#);"
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL)
If rs.RecordCount = 0 Then
MsgBox "There are no records for this date", vbOKOnly
DoCmd.Close acForm, "frmDateSelection3"
Else
DoCmd.TransferSpreadsheet acExport, , "qryCustInfo", BrowseSaveXLS(CurDir(), "Save As")
DoCmd.Close acForm, "frmDateSelection3"
End If
I don't see what I'm doing wrong - but the error I get is:
Runtime error 3061
Too few paramaters. Expected 1.
I can paste that same SQL string (except putting the value of the variable in) into a regular query in Access and it works just fine.
I don't understand what I'm doing wrong.
All this is supposed to do is export a spreadsheet for a date specified in a form, and before doing the export, notify you if there are no records instead of exporting a sheet with nothing in it.
Help!