DefaultValue

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to use Jet SQL to modify field properties such as DefaultValue?

I know it may be something like ALTER TABLE but I cant find any text on its
usage
 
Yes, but that is a Jet 4.0 extension and works only with ADO, under standard
settings. There is also an ugly bug (in the parser) if you use the ending
semicolon, so don't use one, in *that* case. In the immediate (debug) window
(NOT in the query designer):


CurrentProject.Connection.Execute "ALTER TABLE tableName ALTER COLUMN
fieldName SET DEFAULT defaultValue "

You can also put parenthesis around the default value, if you want, or use a
default string value even for a numerical field (as long as the string is a
valid number), but I fail to see why someone would do that.


CurrentProject.Connection.Execute "ALTER TABLE tableName ALTER COLUMN
columnName DROP DEFAULT"


to drop a default value.


Hoping it may help,
Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top