Syntax error in Alter Table statement - Run-time error '3293': (1 Viewer)

JGravesNBS

Registered User.
Local time
Yesterday, 18:03
Joined
Apr 5, 2014
Messages
58
I'm getting following error message on following Alter command:

Run-time error '3293':
Syntax error in Alter Table statement

dbs.Execute "ALTER TABLE Customers ADD COLUMN dtmDateCreate DATE DEFAULT Date();"

Also, what is the syntax to add the following to the Alter statement?

Format mm/dd/yyyy
Input Mask 90/90/99;0;_
Caption Create
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 18:03
Joined
Aug 30, 2003
Messages
36,125
I wonder if it's this from MSDN:

The DEFAULT statement can be executed only through the Access OLE DB provider and ADO. It will return an error message if used through the Access SQL View user interface.
 

JHB

Have been here a while
Local time
Today, 03:03
Joined
Jun 17, 2012
Messages
7,732
You can change the field property after you've created the field.
So first:
Code:
dbs.Execute "ALTER TABLE Customers ADD COLUMN dtmDateCreate DATE;
Then
Code:
dbs.TableDefs("Customers").Fields("dtmDateCreate").DefaultValue = "Date()"
 

JGravesNBS

Registered User.
Local time
Yesterday, 18:03
Joined
Apr 5, 2014
Messages
58
Thanks for the solution that worked

How about the syntax to add the following to dtmDateCreate

Format mm/dd/yyyy
Input Mask 90/90/99;0;_
Caption Create
Required Yes
Indexed Yes

dbs.TableDefs("Customers").Fields("dtmDateCreate").Format = "mm/dd/yyyy)"

Returns Compile error: Method or data member not found
 

Users who are viewing this thread

Top Bottom