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!

Display Mixed Number Formats 1

Status
Not open for further replies.

sxschech

Technical User
Jul 11, 2002
1,033
US
I tried this code which works in Preview, but doesn't on the hard copy print out.

[tt]
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.txtSchoolGroup = "GPA" Then
For i = 1 To 6
Me("txtScore" & i).Format = "Fixed"
Me("txtScore" & i).DecimalPlaces = "2"
Next
End If
End Sub
[/tt]

I also tried placing the code in
Detail_Print(Cancel As Integer, PrintCount As Integer)

In the properties of the text box, I left the Format Blank and tried using Auto and 0 for Decimal places, neither worked for printing.

Results on screen are fine:

[tt]
GROUP A
Description Score1 Score2 Score3
Math 500 350 225
Science 425 380 200
-------------------------------------------

GROUP B
Description
GPA 2.25 3.10 3.25
-------------------------------------------
[/tt]

Results on Paper look like this.
[tt]
GROUP A
Description Score1 Score2 Score3
Math 500.00 350.00 225.00
Science 425.00 380.00 200.00
-------------------------------------------

GROUP B
Description
GPA 2.25 3.10 3.25
-------------------------------------------
[/tt]

 
I think your problem is that everything on your report that is Not GPA is displayed first and has the values you want and then GPA gets formated later. You need to set the format back in your else part of your if statement. You might want a different format. If I was doing this I would also likely set the format type and decimal places values in an If statement and set the properties to the values so as not to repeate the for loop as I did below. I'd also likely explicitly set the properites as it should prove faster.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Me.txtSchoolGroup = "GPA" Then
For i = 1 To 6
Me("txtScore" & i).Format = "Fixed"
Me("txtScore" & i).DecimalPlaces = "2"
Next
Else
For i = 1 To 6
Me("txtScore" & i).Format = "Fixed"
Me("txtScore" & i).DecimalPlaces = "0"
Next

End If

End Sub
 
When I said set the format types and decimal places to values I meant variables. And to think I read that before hitting submit <sigh>.
 
Thank you. Adding the Else code did the trick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top