MrAccessUniversity
New Member
- Joined
- Nov 28, 2011
- Messages
- 3
I recently learned how to set default values for all fields in a table using VB (DAO).
Public Sub Make_defs()
Dim x As Integer
For x = 1 To CurrentDb.TableDefs("import_format").Fields.Count
CurrentDb.TableDefs("import_format").Fields(x - 1).DefaultValue = "=null"
Next
End Sub
I had a table used for importing data into an application and most of the fields default values were a literal string "null". This code was quite simple but most of the samples found on other forums were useless.
Public Sub Make_defs()
Dim x As Integer
For x = 1 To CurrentDb.TableDefs("import_format").Fields.Count
CurrentDb.TableDefs("import_format").Fields(x - 1).DefaultValue = "=null"
Next
End Sub
I had a table used for importing data into an application and most of the fields default values were a literal string "null". This code was quite simple but most of the samples found on other forums were useless.
Last edited: