change numeric default?

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?
 
K

Ken Snell

From the database window, go to Tools | Options and click on Tables/Queries
tab. Set the default numeric field format there.
 
A

Allen Browne

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
 
J

Jaime

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.




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top