PC Review


Reply
Thread Tools Rate Thread

Creating a table in code

 
 
Del
Guest
Posts: n/a
 
      25th Sep 2008
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?
--
Thank you,
Del
 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      25th Sep 2008
DoCmd.RunSQL "CREATE TABLE [" & strExcelTableName & "] ([" & strColumnName &
"] Memo);"

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

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Del" <(E-Mail Removed)> wrote in message
news:4E982758-0967-49E6-8873-(E-Mail Removed)...
>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?
> --
> Thank you,
> Del



 
Reply With Quote
 
Del
Guest
Posts: n/a
 
      26th Sep 2008
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" wrote:

> DoCmd.RunSQL "CREATE TABLE [" & strExcelTableName & "] ([" & strColumnName &
> "] Memo);"
>
> Or, better yet, don't allow spaces in the names.
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Del" <(E-Mail Removed)> wrote in message
> news:4E982758-0967-49E6-8873-(E-Mail Removed)...
> >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?
> > --
> > Thank you,
> > Del

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Make Table in Back End using VBA code is not creating the table Hugh self taught Microsoft Access VBA Modules 3 18th Jan 2010 01:57 PM
Creating table in code John Microsoft Access 1 21st Jun 2009 07:31 PM
Creating a table in code =?Utf-8?B?R2xlbm4gU3VnZ3M=?= Microsoft Access VBA Modules 2 30th Jan 2007 04:32 PM
Code for Creating Table Url Ons Microsoft Access VBA Modules 1 19th Jul 2003 06:40 PM
creating on-the-fly asp:table in the code file Murtix Van Basten Microsoft ASP .NET 2 25th Jun 2003 08:19 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:43 PM.