Number format in queries

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hopefully this is easy.

Does anyone know if it is possible to change the default number format for
number fields to "standard" (or any other format). I'm getting very tired of
going into properties all the time to flip the setting so that large numbers
are actually readable.


Thanks,

Tom.
 
Tom Telford said:
Does anyone know if it is possible to change the default number format for
number fields to "standard" (or any other format). I'm getting very tired
of
going into properties all the time to flip the setting so that large
numbers
are actually readable.

Tom, there's not an easy way to do this in the interface, but you can do it
programmatically. Adjust the Select Case part for the field types you want
to handle.

Public Function FormatQueryNumbers(Optional strQueryName As String)
'Purpose: Set the Format of numeric fields in queries to Standard.
'Argument: Name of query to set. If blank, ALL queries are set.
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strMsg As String

Set db = CurrentDb()
If strQueryName <> vbNullString Then
Set qdf = db.QueryDefs(strQueryName)
strMsg = "About to set the Format to Standard for all numeric fields
in query " & strQueryName & vbCrLf & "Proceed?"
If MsgBox(strMsg, vbYesNo, "Confirm") = vbYes Then
Call FormatQueryNumbers2(qdf)
End If
Else
strMsg = "About to set the Format to Standard for all numeric fields
in ALL QUERIES in this database." & vbCrLf & "Proceed?"
If MsgBox(strMsg, vbYesNo, "Confirm") = vbYes Then
For Each qdf In db.QueryDefs
If Not (qdf.Name Like "~*") Then
Call FormatQueryNumbers2(qdf)
End If
Next
End If
End If

Set qdf = Nothing
Set db = Nothing
End Function

Private Function FormatQueryNumbers2(qdf As DAO.QueryDef)
Dim fld As DAO.Field

For Each fld In qdf.Fields
Select Case fld.Type
Case dbDouble, dbSingle ', dbLong, dbInteger, dbByte
Call SetPropertyDAO(fld, "Format", dbText, "Standard")
Debug.Print qdf.Name & "." & fld.Name
End Select
Next
End Function
 
Thanks Allen. Does this change the default for all future queries in the
database as well?

Thanks,

Tom.



:
 
No: you need to run it over specific queries, so future ones are not
affected.
 

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

Back
Top