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!

Formatting part of an unbound control

Status
Not open for further replies.

melaniecarr23

Programmer
May 2, 2005
79
US
Two questions on formatting in an unbound control:

1) If the unbound control includes text and numbers (ex: ="You have $" & [dollars_left] & "left to spend."
Can I bold the text portion of this, but leave the calculated field unformatted?

2) Can I change the way a calculated field is displayed within an unbound control? (showing $2.50 instead of $2.5)

Thanks!
 
melanie
The answer to (2) is...
Format([YourField],"currency")

Tom
 
Lot of people would say no to the first question, I'd probably be inclined to that too, but have a look at the lady report, in the lady.mdb here at Stephen Lebans, in particular the tbLady control.

I haven't used this, but just looked at the sample mentioned, which seems to work. See if you find it worthwhile adding it to your project.

Roy-Vidar
 
This isn't all the difficult with a little code. Assuming you have a text box (maybe invisible) name txtDollars_Left bound to your field.

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Dim intTop As Integer
    Dim intLeft As Integer
    Me.FontSize = 20
    Me.FontName = "Arial"
    intTop = 360 '1/4 inches
    intLeft = 1440 '1 inch
    Me.CurrentY = intTop
    Me.CurrentX = intLeft
    Me.Print "You have $"
    Me.CurrentY = intTop
    Me.FontBold = True
    If Me.txtDollars_Left < 0 Then
        'print negative numbers in red
        Me.ForeColor = vbRed
    End If
    Me.Print Trim(Me.txtDollars_Left)
    Me.CurrentY = intTop
    Me.FontBold = False
    Me.ForeColor = vbBlack
    Me.Print " left to spend."
End Sub

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Thanks so much! I ended up going the easier route of putting the information I wanted to stand out on another line bolded, but will definitely use the Format([field],"currency") to make the numbers show how I want them. You guys rock!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top