Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 08-30-2011, 04:33 AM   #1
Matt_Lavoie
Newly Registered User
 
Join Date: Aug 2011
Posts: 13
Thanks: 3
Thanked 0 Times in 0 Posts
Matt_Lavoie is on a distinguished road
Question Error 3141 - Reserved word or mispelling

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 by Matt_Lavoie; 08-30-2011 at 04:47 AM.
Matt_Lavoie is offline   Reply With Quote
Old 08-30-2011, 05:29 AM   #2
SteveH2508
Newly Registered User
 
Join Date: Feb 2011
Location: Chelsea, London, England
Posts: 75
Thanks: 0
Thanked 8 Times in 8 Posts
SteveH2508 is on a distinguished road
Send a message via Yahoo to SteveH2508
Re: Error 3141 - Reserved word or mispelling

The other suspect would be your field called AutoNumber.
SteveH2508 is offline   Reply With Quote
Old 08-30-2011, 05:47 AM   #3
Matt_Lavoie
Newly Registered User
 
Join Date: Aug 2011
Posts: 13
Thanks: 3
Thanked 0 Times in 0 Posts
Matt_Lavoie is on a distinguished road
Re: Error 3141 - Reserved word or mispelling

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.

Matt_Lavoie is offline   Reply With Quote
Old 08-30-2011, 07:14 AM   #4
SteveH2508
Newly Registered User
 
Join Date: Feb 2011
Location: Chelsea, London, England
Posts: 75
Thanks: 0
Thanked 8 Times in 8 Posts
SteveH2508 is on a distinguished road
Send a message via Yahoo to SteveH2508
Re: Error 3141 - Reserved word or mispelling

You have a comma before the FROM clause - that might be an issue.
SteveH2508 is offline   Reply With Quote
The Following User Says Thank You to SteveH2508 For This Useful Post:
Matt_Lavoie (08-30-2011)
Old 08-30-2011, 07:27 AM   #5
Matt_Lavoie
Newly Registered User
 
Join Date: Aug 2011
Posts: 13
Thanks: 3
Thanked 0 Times in 0 Posts
Matt_Lavoie is on a distinguished road
Re: Error 3141 - Reserved word or mispelling

Quote:
Originally Posted by SteveH2508 View Post
You have a comma before the FROM clause - that might be an issue.
That was it! Thanks Steve.

Matt_Lavoie is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL stopped working "reserved word" error tho28199 Modules & VBA 4 04-29-2011 07:33 AM
SQL Reserved word error emorris1000 Queries 2 04-13-2011 02:01 PM
Have I Stumbled Across a Reserved Word? gray Forms 5 02-17-2011 05:11 AM
Word Reserved JPaulo General 6 01-21-2010 08:12 AM
Is there a way to use a reserved word in a field name? Ai_Jun_Zhang Tables 5 05-16-2005 09:18 PM




All times are GMT -8. The time now is 03:43 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World