Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Access create table default values

Status
Not open for further replies.

zyphon

Programmer
Jun 30, 2003
1
ZA
I have used the following query :
CREATE TABLE messages([ID]autoincrement,[user] text,[message] memo,[topicID] integer,[msgdate] date,PRIMARY KEY ([ID]));
which works fine. I need to find default values for the fields.
Thanks.
 
Assuming you're using Access tables, you can get the DAO TableDef object which has a collection of Fields which have the property "DefaultValue".

i.e.
Code:
    CurrentDB.TableDefs("Table1").Fields("Field1").DefaultValue
    'or
    CurrentDB.TableDefs!Table1!Field1.DefaultValue


I've never needed to change this in code, so I don't know for sure, but I believe you will have to re-append the field to the fields colelction or run some sort of "Update" to save the changes. Or maybe not.



Alternately, consider *NOT* deleting the table in the first place so you don't have to re-set the default value every time. Instead delete the table *contents*, and APPEND those contents. Easier in the long run. And you get to keep relationships!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top