SQL Statements not working in VB

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

I'm trying to learn the use of SQL in lieu of using queries all the time in
Access 2002.

When I enter any SQL statement in the VB section, I get a "Compile Error.
Expected end of statement."

My example is:

INSERT INTO tblExpenseLocations ( ExpenseLocations) .... etc

I get the message as soon as I press enter to go to the next line to
continue the statement.

Do I need a reference loaded or something?
 
Joe said:
I'm trying to learn the use of SQL in lieu of using queries all the time in
Access 2002.

When I enter any SQL statement in the VB section, I get a "Compile Error.
Expected end of statement."

My example is:

INSERT INTO tblExpenseLocations ( ExpenseLocations) .... etc

I get the message as soon as I press enter to go to the next line to
continue the statement.

Do I need a reference loaded or something?


The VBA environment does not understand SQL.

There are several Access, DAO or ADO methods that will pass
an SQL statement on to the db engine for processing, but the
SQL statement must be a string to do that. For example:

Dim strSQL As String
strSQL = "SELECT * FROM table"
RunSQL strSQL
 

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

Back
Top