change numeric default?

  • Thread starter Thread starter Jaime
  • Start date Start date
J

Jaime

Is there a way to permanently change the default value for
numeric values so that when setting up a new table I won't
have to do this for every numeric field?
 
From the database window, go to Tools | Options and click on Tables/Queries
tab. Set the default numeric field format there.
 
Jaime, I think you are asking if there is a way to stop Access assigning
zero as the Default Value whenever you create a new Number field in a table?

I really wish there was: it is really counter-productuctive, and messes up
foreign key fields.

Programmatically, you can remove the default value from the Number fields
like this:

Dim tdf As DAO.TableDef 'Table nominated in argument.
Dim fld As DAO.Field 'Each field.

Set tdf = dbEngine(0)(0).TableDefs("MyTable")

For each fld in tdf.Fields
Select Case fld.Type
Case dbLong, dbInteger, dbByte, dbDouble, dbSingle, dbDecimal
fld.DefaultValue = vbNullString
End Select
Next

Set fld = Nothing
Set tdf =Nothing
 
Thanks, that worked great.
Jaime
-----Original Message-----
Jaime, I think you are asking if there is a way to stop Access assigning
zero as the Default Value whenever you create a new Number field in a table?

I really wish there was: it is really counter- productuctive, and messes up
foreign key fields.

Programmatically, you can remove the default value from the Number fields
like this:

Dim tdf As DAO.TableDef 'Table nominated in argument.
Dim fld As DAO.Field 'Each field.

Set tdf = dbEngine(0)(0).TableDefs("MyTable")

For each fld in tdf.Fields
Select Case fld.Type
Case dbLong, dbInteger, dbByte, dbDouble, dbSingle, dbDecimal
fld.DefaultValue = vbNullString
End Select
Next

Set fld = Nothing
Set tdf =Nothing
--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.




.
 
Back
Top