gmaxey
05-19-2013, 12:30 PM
Hi,
I'm am trying to write some code that uses DAO (and I don' really even know what that means) and use ADODB instead.
In a part of the code a new database table (Access *.mdb format file) is created using the following statement:
Dim strVariableName
Dim tdNewTable As TableDef
strVariableName = "Three Word Title"
Set tdNewTable = dbMyData.CreateTableDef(strVariableName)
I have figured out how to add a similar table using ADODB but it only works if strVariableName is a single word:
strVariableName = "Table1"
m_oConn.Execute "CREATE TABLE " & stVariableName & "(" & _
"fldAlpha VARCHAR(1) NOT NULL, fldBravo VARCHAR(2) NOT NULL)"
If I used strVariableName = "Three Word Title" I get a "Syntax Error in CREATE TABLE statement.
So I know that it is possible to create a table titled with two or more words in a access data base (because the old code does that). My question is how do I use the CREATE TABLE statement to create a table titled with two or more words.
The reason I need to use two or more word table titles is these tables titles are later queried to populate a userform list. I would llike for my listed titles to be meaningful and look clean as they do now:
Bird Migration Habits
Cat Feeding Habits
Not
BirdMigrationHabits
Cat_Feeding_Habits
etc.
Thanks.
I'm am trying to write some code that uses DAO (and I don' really even know what that means) and use ADODB instead.
In a part of the code a new database table (Access *.mdb format file) is created using the following statement:
Dim strVariableName
Dim tdNewTable As TableDef
strVariableName = "Three Word Title"
Set tdNewTable = dbMyData.CreateTableDef(strVariableName)
I have figured out how to add a similar table using ADODB but it only works if strVariableName is a single word:
strVariableName = "Table1"
m_oConn.Execute "CREATE TABLE " & stVariableName & "(" & _
"fldAlpha VARCHAR(1) NOT NULL, fldBravo VARCHAR(2) NOT NULL)"
If I used strVariableName = "Three Word Title" I get a "Syntax Error in CREATE TABLE statement.
So I know that it is possible to create a table titled with two or more words in a access data base (because the old code does that). My question is how do I use the CREATE TABLE statement to create a table titled with two or more words.
The reason I need to use two or more word table titles is these tables titles are later queried to populate a userform list. I would llike for my listed titles to be meaningful and look clean as they do now:
Bird Migration Habits
Cat Feeding Habits
Not
BirdMigrationHabits
Cat_Feeding_Habits
etc.
Thanks.