When opening a form I get the error:
Error 3141 in the frmHaulageProduction Form_Open Subroutine: The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.
I'm new to VBA, but I've had this before and know that it is probably just a stupid mistake. I've tried for hours though and can't find it. I've retyped all the code and did no better. This form opens with some code which only displays records with a particular date.
The only thing in Form_Open is
Me.RecordSource = pstrHaulProdSQL
Inside a module is a bit with this:
pstrHaulProdSQL = "SELECT tblHaulageProduction.AutoNumber, tblHaulageProduction.Date, " & _
"tblHaulageProduction.Pit, tblHaulageProduction.Ledge, tblHaulageProduction.DestinationName, " & _
"tblHaulageProduction.CrusherHoursDelay, tblHaulageProduction.CrusherHoursNet, " & _
"tblHaulageProduction.WasherHoursDelay, tblHaulageProduction.WasherHoursNet, " & _
"tblHaulageProduction.DelayCause, tblHaulageProduction.GrossTons, " & _
"tblHaulageProduction.CrusherFines, tblHaulageProduction.EastGateFines, " & _
"tblHaulageProduction.FinesBackToQuarry, tblHaulageProduction.NetTons, " & _
"tblHaulageProduction.Shift, FROM tblHaulageProduction " & _
"WHERE (((tblHaulageProduction.Date)=#" & pdteHaulProdDate & "#));"
I know that Date is a reserve word and I'm using it as a field name, however I've formatted other forms in this file like this and they have worked.
pdteHaulProdDate is declared as an actual Date and is set to the particular day that I want to display records for.
Thanks in advance for any little bit of advice you can offer me. This has been driving me crazy!