Error Message -- SELECT statement includes...

Princessboko

Board Regular
Joined
Nov 3, 2002
Messages
73
I have a database that I'm trying to build a form for. I go into the Query Builder and select all the fields I want to be on the form. Before I leave the Query Builder I run the query and see all the fields. When I leave the Query Builder and try to look at the form I get this error:

"The SELECT statement includes a reserved word or an argument name that is misspellec or missing, or the punctuation is incorrect"

Here's my statement:

SELECT Employees.EmployeeId, Employees.CaseNumber, Employees.FName, Employees.LName, Employees.StAddress, Employees.City, Employees.State, Employees.Zipcode, Employees.Phone, Employees.Dept, Employees.JobCat, Employees.Description, Source.SourceID, Source.EmployeeID, Source.SourceName, Source.SourceUknwn, Source.AttendingDr, Source.KnownHiv, Source.HistoryIV, Source.ManWMan, Source.CommWkr, Source.NonAbove, Source.SourceHepB, Source.SourceHepC, Source.SourceHIV, Source.DateHepb, Source.DateHepC, Source.DateHiv, Source.SourceResultsHepB, Source.SourceResultsHepC, Source.SourceResultsHiv, Source.EHRN, BaselineTest.BaselineID, BaselineTest.SourceID, BaselineTest.EmployNot, BaselineTest.SourceDocNot, BaselineTest.HBVExposure, BaselineTest.BaseABLevel, BaselineTest.ABTesDate, BaselineTest.TestDone, BaselineTest.BaseHepb, BaselineTest.HepbDrDate, BaselineTest.BaseHepc, BaselineTest.HepCDrDate, BaselineTest.BaseHIV, BaselineTest.ConsentSign, BaselineTest.HIVDrDate, BaselineTest.ClotStudy, BaselineTest.ClotDrDate, BaselineTest.ResultsID, BaselineTest.SumDate, BaselineTest.Pep, BaselineTest.HepbVac, BaselineTest.Comment, BaselineTest.SixWk, Results.ResultsID, Results.BaselineId, Results.HIVSixWDue, Results.HIVSixWDone, Results.HIVResult, Results.HIVTwelvWDue, Results.HIVTwelvWDone, Results.HIVTwelvWResult, Results.HIVSixMDue, Results.HIVSixMDone, Results.HIVSixMResult, Results.HBABDue, Results.HBABDone, Results.HBABResult, Results.HBABTwoDue, Results.HBABTwoDone, Results.HBABTwoResult, Results.LiverDue, Results.LiverDone, Results.LiverResult, Results.ResultComment
FROM ((Employees INNER JOIN Source ON Employees.EmployeeId = Source.EmployeeID) INNER JOIN BaselineTest ON Source.SourceID = BaselineTest.SourceID) INNER JOIN Results ON BaselineTest.BaselineID = Results.BaselineId;

I've looked at this so much I can't see the error. Any suggestions would be most appreciated.

Thanks! :oops:
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Your SELECT statement contains an awful lot of fields. I would try re-creating the query, adding a few fields at a time to see if you can pinpoint exactly what command is causing the error.
 
Upvote 0
The query must be fine if you are able to execute it. It sounds to me like there is some problem with the form. Have you checked the data source and any filters of the form?
 
Upvote 0
I didn't see anything obvious in the query, although it is long. Use the Form Builder Wizard and recreate it from scratch to see if it can place all the fields.

You might try this though - you can simplify queries manually following the format "SELECT * FROM tblName" by editing the SQL version directly. This does make one broad assumption. You are including ALL fields from the indicated tables into your query.

In your case it would be:

SELECT Employees.*, Source.*, BaselineTest.*, Results.* FROM ((Employees INNER JOIN Source ON Employees.EmployeeId = Source.EmployeeID) INNER JOIN BaselineTest ON Source.SourceID = BaselineTest.SourceID) INNER JOIN Results ON BaselineTest.BaselineID = Results.BaselineId;

Mike
 
Upvote 0
Thanks all. Last night I recreated the whole thing and it seems to be working fine this morning.

Thanks all for your help.
 
Upvote 0

Forum statistics

Threads
1,221,607
Messages
6,160,787
Members
451,671
Latest member
kkeller10

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top