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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

want to display -ve number in this format: (-1) 1

Status
Not open for further replies.

hengsin

Technical User
Mar 26, 2003
128
MY
i have a text box in a report. The value calculated is from query. The value calculated can be positive number and negative number. Now what i want to do is when the calculated value is negative number, it will be display on this format
(-1)
(-10)

Can i know how to do it and where should i put the code?
I tried something like that but it doesn't work. I put this code on

Dim strDueDay As String
strDueDay = Me!txtDueDay
If strDueDay < 0 Then
strDueDay = &quot;(&quot; & strDueDay & &quot;)&quot;
End If

On Open event but id doesn't work.

 
I just figure out something. Please look at the code below:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me!txtDueDay < 0 Then

Dim str As String
str = Me!txtDueDay
str = &quot;(&quot; & Me!txtDueDay.Text & &quot;)&quot;
MsgBox (str)

End If

End Sub

I'm able to get the negative number with bracket around but i dont know how to assign it back to Me!txtDueDay. When i tried something like that:

Me!txtDueDay = str

I got the error message: You can't assign a value to this object. Can anyone here know how to do it?
 
Why don't you just use the format property to assign the parenthesis.

put this into the format propoerty of the text box:

0;(-0)
 
thanks, JohnLowell. I didn't know that the format property can be done is this way. Anyway, thanks for the help.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top