Creating a table using Strings for field names

E

Ed Handley

Hi,

I have a form for which I want to create a tempory table with field names
based on strings generated in the code but I keep getting an error (3292:
Syntax Error in defenition, with no help option) when I try to run the code.

I am using access 2000, and have attached a sample of the code below. Can
anyone help please?

Ed Handley

strM1 = Format(dteMon1, "mmmm yy")
strM2 = Format(dteMon2, "mmmm yy")
strM3 = Format(dteMon3, "mmmm yy")
strM4 = Format(dteMon4, "mmmm yy")
strM5 = Format(dteMon5, "mmmm yy")
strM6 = Format(dteMon6, "mmmm yy")
strM7 = Format(dteMon7, "mmmm yy")
strM8 = Format(dteMon8, "mmmm yy")
strM9 = Format(dteMon9, "mmmm yy")
strM10 = Format(dteMon10, "mmmm yy")
strM11 = Format(dteMon11, "mmmm yy")
strM12 = Format(dteMon12, "mmmm yy")
DoCmd.RunSQL "CREATE TABLE [tblClaims inventory] ([" & strM1 & "])
 
M

Michael J. Strickland

Ed Handley said:
Hi,

I have a form for which I want to create a tempory table with field names
based on strings generated in the code but I keep getting an error (3292:
Syntax Error in defenition, with no help option) when I try to run the
code.

I am using access 2000, and have attached a sample of the code below. Can
anyone help please?

Ed Handley

strM1 = Format(dteMon1, "mmmm yy")
strM2 = Format(dteMon2, "mmmm yy")
strM3 = Format(dteMon3, "mmmm yy")
strM4 = Format(dteMon4, "mmmm yy")
strM5 = Format(dteMon5, "mmmm yy")
strM6 = Format(dteMon6, "mmmm yy")
strM7 = Format(dteMon7, "mmmm yy")
strM8 = Format(dteMon8, "mmmm yy")
strM9 = Format(dteMon9, "mmmm yy")
strM10 = Format(dteMon10, "mmmm yy")
strM11 = Format(dteMon11, "mmmm yy")
strM12 = Format(dteMon12, "mmmm yy")
DoCmd.RunSQL "CREATE TABLE [tblClaims inventory] ([" & strM1 & "])

I think you need another quote after the last bracket.
i.e.
DoCmd.RunSQL "CREATE TABLE [tblClaims inventory] ([" & strM1 & "]")


--
 
Top