Creating a table in code

  • Thread starter Thread starter Del
  • Start date Start date
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?
 
DoCmd.RunSQL "CREATE TABLE [" & strExcelTableName & "] ([" & strColumnName &
"] Memo);"

Or, better yet, don't allow spaces in the names.
 
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.
 
Back
Top