Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select statement error

Status
Not open for further replies.

nicmar

Programmer
Mar 4, 2003
11
US
I am trying to get the average, minimum, and maximum from a table and display the asnwers in text boxes on my report.

Here is my code:

gstrSQL = "SELECT Avg(SData.Test1) AS AvgScore, Min
(SData.Test1) AS MinScore, Max(SData.Test1) AS MaxScore"
gstrSQL = gstrSQL & "FROM SData;"

Set rsTotalStudents = gdbAll.OpenRecordset(gstrSQL,
dbOpenSnapshot)

txtHighGrade = rsTotalStudents![MaxScore]
txtLowGrade = rsTotalStudents![MinScore]
txtAverageGrade = rsTotalStudents![AvgScore]

rsTotalStudents.Close

Here is the error I am getting:

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

It highlights the Set rsTotalStudents Line after giving me this error. I have went through and checked to see what is working and the SQL statement is o-kay. I have starred at this code way too long, I can not see the problem. Any comments/suggestions are greatly appreciated.

Thank You,
nicmar
 
nicmar, you have a run on sentence. You need to put a space between " and From in this line
" From SData"
If you debug.print gstrSQL you will see the error.

Paul
 
Thnk You Paul. I knew it was something little but I stared at it too long!!

Thanks again,
nicmar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top