Creating a table in code

D

Del

I am creating a table in Access 2000 to import data from an Excel
spreadsheet. It is necessary to name the table and its fields exactly the
same as the spreadsheet and its header name for the column. This code works
fine if there are no spaces in the header name.

DoCmd.RunSQL "CREATE TABLE " & strExcelTableName & " (" & strColumnName & "
Memo);"

But when the header name has a space it generates a syntax error in the
field definition. What code do I need to deal with these spaces?
 
D

Douglas J. Steele

DoCmd.RunSQL "CREATE TABLE [" & strExcelTableName & "] ([" & strColumnName &
"] Memo);"

Or, better yet, don't allow spaces in the names.
 
D

Del

thanks for the help. i'll have to try it monday - long busy weekend.

I would rather not have the spaces in the column names but i don't have a
choice.
--
Thank you,
Del


Douglas J. Steele said:
DoCmd.RunSQL "CREATE TABLE [" & strExcelTableName & "] ([" & strColumnName &
"] Memo);"

Or, better yet, don't allow spaces in the names.
 

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