Error 3141 - Reserved word or mispelling (1 Viewer)

Matt_Lavoie

Registered User.
Local time
Today, 05:54
Joined
Aug 24, 2011
Messages
13
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
Code:
Me.RecordSource = pstrHaulProdSQL

Inside a module is a bit with this:
Code:
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!
 
Last edited:

SteveH2508

Registered User.
Local time
Today, 10:54
Joined
Feb 22, 2011
Messages
75
The other suspect would be your field called AutoNumber.
 

Matt_Lavoie

Registered User.
Local time
Today, 05:54
Joined
Aug 24, 2011
Messages
13
Oh yeah I didn't see that one. I have a half dozen other forms in which I've called it AutoNumber too though. For example:
Code:
pstrEGateSQL = "SELECT tblEastGateProduction.AutoNumber, tblEastGateProduction.Date, " & _
    "tblEastGateProduction.TrucksLoaded, tblEastGateProduction.HoursRan, tblEastGateProduction.PlannedDelay, tblEastGateProduction.EmergencyDelay, " & _
    "tblEastGateProduction.TonsHauled, tblEastGateProduction.TrucksLoaded, tblEastGateProduction.TonsSold, tblEastGateProduction.PCSold FROM tblEastGateProduction " & _
    "WHERE (((tblEastGateProduction.Date)=#" & pdteEGateDate & "#));"
This is the next section in the very same module and it has no problems.
 

SteveH2508

Registered User.
Local time
Today, 10:54
Joined
Feb 22, 2011
Messages
75
You have a comma before the FROM clause - that might be an issue.
 

Users who are viewing this thread

Top Bottom