setting default value of a field in a table (not on a form)

homer2002

Registered User.
Local time
Today, 07:44
Joined
Aug 27, 2002
Messages
152
how do you set the default value of a field in a form using VBA?

My database is split so the table is linked.


I tried

table.defaultvalue = "THIS IS A DEFAULT VALUE"

guess what :-)
it didn't work.

Has anyone any ideas on how to do this?
 
Most of the field types have a default value you can specify, look in table design.
 
Private Sub Command1_Click()
Dim tdf As TableDef
Dim db As DAO.Database

Set db = CurrentDb()

Set tdf = db.TableDefs("Table")

tdf.Fields("Field").DefaultValue = 1024

Set tdf = Nothing
Set db = Nothing
End Sub
 

Users who are viewing this thread

Back
Top Bottom