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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid SQL statement

Status
Not open for further replies.

JezzaHyde

Programmer
Jul 29, 2002
29
0
0
AU
Hey folks, this one is causing me some grief. All i'm trying to do is open a recordset, but my code keeps falling over at the sql statement.

This is the relevant part of the code:

Code:
  Dim strSQL As String
    
  strSQL = "SELECT * FROM Reminder WHERE Reminder.RemDate = Date()"

Maybe i'm just stupid and i'm missing an obvious flaw here...but i can't see why this results in an "Invalid SQL statement" error.

Any help??

-Jezza
 
I see nothing wrong with your SQL string here. What are you doing with it after you setup this string variable strSQL?

Are you trying to do a DoCmd.RunSQL strSQL?

If you are that is your problem. Your strSQL code is a Select SQL string and the DoCmd.RunSQL command is only for Action Queries which ONLY include append, delete, make-table and update queries. A simple select cannot be run using this type of command.

Now you can update the .SQL property of an existing query and then perform a DoCmd.OpenQuery command on that query. I can show you how to do that if you would like.

Just let me know if this is the problem. Bob Scriver
 
Ahhhh, thank you very much Bob. I did not know that about the runsql command.

Thanks

-Jezza
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top