select syntax error Help!

?

********

I get a "syntax error(missing operator) '* where roncheck_access.DATE
Between #1/1/99# And #12/31/00#' ". This is in the select statement. The date
values coming in from the date controls are correct as seen in the error.

I'm looking to get records for date> 1/1/99 and date <12/31/00 .What
am I doing wrong? Thanks.

Private Sub db_betw_dates_obj_MouseDown(Button As Integer, Shift As Integer,
X As Single, Y As
Single)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String

Set db = CurrentDb

strSQL = "select * " _
& "where roncheck_access.DATE Between " _
& "#" & start_date_cal.Value & "# And #" & end_date_cal.Value & "#;"
Set rs = db.OpenRecordset(strSQL)
End Sub
 
T

TomU

You statement is missing the FROM clause:
strSQL = "select * FROM roncheck_access" _
& "where roncheck_access.DATE Between " _
& "#" & start_date_cal.Value & "# And #" & end_date_cal.Value & "#;"

TomU
 
?

********

No more syntax error,but the data isn't being restricted to the date range.
DATE is a field in the roncheck_access table. Is the select statement coded
properly? Thanks.
 
?

********

******** said:
No more syntax error,but the data isn't being restricted to the date range.
DATE is a field in the roncheck_access table. Is the select statement coded
properly? The start and end date data is correct when viewed in debug watch. The select statement is now

strSQL = "select * FROM roncheck_access" _
.. The date values coming in from the date controls are correct as seen in
the error.
 
D

Douglas J. Steele

Date is a poor choice for a field name, as it's a reserved word. Try
renaming the field if you can. If you can't, try putting square brackets
around it, like roncheck_access.[DATE]

Also, consider using a 4 digit year.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top