SQL Statements not working in VB

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?
 
M

Marshall Barton

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
 
Top