Link to home
Start Free TrialLog in
Avatar of j e
j e

asked on

Access 3067 error using VBA sql

I keep getting 3067 error when running sql in vba.  "Query input must contain at least one table or query."

I'm running code that will generate multiple tables based upon values in another table.  

I cloned code from another module that works fine and just replaced the table name and variable.  So -- I'm not sure why this doesn't work.

st_tablename = "t_PLINE_x-x--"
st_PROFILE = PLINEx-x--

            stsql = "SELECT t_File4_for_review_PLINE2.* INTO " & st_tablename & _
                    " FROM t_File4_for_review_PLINE2 " & _
                    " WHERE (((t_File4_for_review_PLINE2.[PROFILE3])=" & "'" & st_PROFILE & "'" & " ));"

Attached is translated sql.

I've looked through some of the solutions online -- and yes I have a space before the 'From' statement.

What am I missing?

Thanks for your help,
je
Access-3067----sql.png
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

For start you are missing the double quotes here
st_PROFILE = PLINEx-x--
should be
st_PROFILE = "PLINEx-x--"
By fixing this i get this sql
SELECT t_File4_for_review_PLINE2.* INTO t_PLINE_x-x-- FROM t_File4_for_review_PLINE2  WHERE (((t_File4_for_review_PLINE2.[PROFILE3])='PLINEx-x--' ));

Open in new window

Avatar of j e
j e

ASKER

Thanks John,

Yes - that's what I have .  I was just providing the value.  The attachment shows the resulting sql statement - which matches what you have.
je
So it works or not ?
Avatar of j e

ASKER

No -- not working.  That's the 3067 message issue.
je
Copy paste the query on the Query designer(SQL) and check if it works....also check the names of the tables ..they are a bit unusual and you might missing a character
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of j e

ASKER

Thank you!
You're welcome.