Formatting Fields in VBA

With the exception of composite fields, VBA returns report field values without any formatting. For instance, VBA returns the phone number (701) 555-0100 Ext. 1772 as 70155501001772. Likewise, VBA returns the currency value $10.56 as 10.56000.

This article will show how to format a field in VBA

 

 To format a report field value, use VBA’s Format function. The Format function allows you to define a format string for a specific field type (string or numeric). The following example uses the Format function to format the fax number string field:  

 

MsgBox (Fax)
'Displays 70155501001772
'Use the format function to format the string
Format(Fax, "(@@@) @@@-@@@@ Ext. @@@@")
MsgBox Fax
'Displays (701) 555-0100 Ext. 1772

RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences