Avatar of Andy Brown
Andy Brown
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Set default value for a field - via VBA

Is it possible to change the deafult value of a field (within a table), via VBA?
Microsoft Access

Avatar of undefined
Last Comment
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

8/22/2022 - Mon
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

Something like this:


    Dim dbs As Database
    Dim fld As DAO.Field
    Set dbs = CurrentDb
    Set fld = dbs.TableDefs("YourTableName").Fields("YourFieldName")
    fld.DefaultValue = 0

    Set fld = Nothing
    Set dbs = Nothing

mx
ASKER CERTIFIED SOLUTION
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Andy Brown

ASKER
MX - As always - you are a Genius - Thank you :O)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

You are welcome ...

mx
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23