Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format Syntax in a report text field

Status
Not open for further replies.

pcdaveh

Technical User
Sep 26, 2000
213
US
What is the proper syntax to set the format of a text field in a report at run-time.

txtMytext = 6900

Format(txtMytext,"###,##0.00)

6,900.00

that's what I'm trying to do in code.

 
You don't have to do it at run time. Just put the following in the "Format" property of the field you want to format in design view.

#,###.00 Jim Lunde
compugeeks@hotmail.com
We all agree your theory is crazy, but is it crazy enough?
 
The reason I want to do it in code is:
The report needs to be viewed with the decimal places when balancing the report to its source but the decimal places are not needed when printed as "Final". I'm trying to set up an if statement that looks at a check box and determines the format property at run time. I'm aware of how to do it at design time.
 
pcdaveh,
Here's what I would do in this instance. There may be an easier way, but this is what comes to mind..

- set up an invisible field on the form, which is bound to the value of the field. Let's name it txtFieldValue. Be sure it's in the same report section that you want the field to be displayed.
- make the visible field unbound. Let's call it txtDisplayValue.
- in the code (in the "Format" event of whichever area that contains the textbox in question) (assuming the checkbox you referred to is called "chkFinal"):

If chkFinal = True Then
txtDisplayValue.Value = _
Format(txtFieldValue.Value, "###,##0")
Else
txtDisplayValue.Value = _
Format(txtFieldValue.Value, "###,##0.00")
End If

Hope that helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top