RunSQL syntax error

A

alex

Hello,

Using Access ‘03

I’m trying to run the following VBA statement:

Dim strTable As String

strTable = InputBox("What's your table called?”)
DoCmd.RunSQL "alter table" & strTable & "add RecordID Counter"

I keep getting a syntax error, however. It has something to do with
strTable. When I change strTable to an actual table name, it works
fine.

Thanks,
alex
 
S

Stefan Hoffmann

hi Alex,
I keep getting a syntax error, however. It has something to do with
strTable. When I change strTable to an actual table name, it works
fine.
There are some spaces missing:

DoCmd.RunSQL "ALTER TABLE [" & strTable & "] ADD RecordID Counter"


mfG
--> stefan <--
 
A

alex

hi Alex,
I keep getting a syntax error, however.  It has something to do with
strTable.  When I change strTable to an actual table name, it works
fine.

There are some spaces missing:

DoCmd.RunSQL "ALTER TABLE [" & strTable & "] ADD RecordID Counter"

mfG
--> stefan <--

Stefan,
That worked perfectly. I thank-you very much!
alex
 

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