RunSQL syntax error

  • Thread starter Thread starter alex
  • Start date Start date
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
 
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 <--
 
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
 
Back
Top