Number datatype format to 'Standard'

J

JA

I need a routine to enumerate through all tables and if the field type is
'Number', I would like to change the format to 'Standard'.
 
J

John W. Vinson

I need a routine to enumerate through all tables and if the field type is
'Number', I would like to change the format to 'Standard'.

Why?

Table datasheets aren't appropriate for viewing or printing data, and you can
set the format of a textbox in a Form or Report to default to Standard (if
indeed it doesn't do so already).

However if you want...

Dim tdf As DAO.Tabledef
Dim fld As DAO.Field
Dim db As DAO.Database
Set db = CurrentDb
For Each tdf In db.Tabledefs
' exclude system tables
If Left(tdf.Name, 4) <> "MSYS" Then
For Each fld In tdf.Fields
Select Case fld.Type
Case dbInteger, dbLong, dbSingle, dbDouble, dbDecimal
fld.Format = "Standard"
Case Else
' do nothing
End Select
End If
Next tdf

Untested air code, back up your database first of course!!!
 
P

pietlinden

I need a routine to enumerate through all tables and if the field type is
'Number', I would like to change the format to 'Standard'.

What is "standard"? Been using Access since 2.0 or so and have never
heard of it. Example?
 
F

fredg

What is "standard"? Been using Access since 2.0 or so and have never
heard of it. Example?

Taken directly from a control's Format property drop-down:
3,456.78

From Format Help
Standard Use the thousand separator; follow the settings specified
in Regional Settings in Windows Control Panel for negative amounts,
decimal symbols, and decimal places.
 
J

John W. Vinson

Love this air code stuff :)
My air code would add one line:


Next fld

--

That would run a LOT faster.... thanks Dave!

(JA: my untested code had an infinite loop that would never complete)
 

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