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

Negative amount display help

Status
Not open for further replies.

vince99

IS-IT--Management
Mar 1, 2001
63
US
Lets say on a form I have a check box for returns and refunds. What I want to do is:

if the check box is checked, and item that is selected, should display a negative amount in the total field.

Thanks

 
Hi Vince. I have to make an assumption or two here and if not true, this won't work: Your total field is the line total of one record. It is not a calculated field. If so:

Place your form in design view. Double-click on your checkbox. This will pop up its "properties" dialog. Find the events tab, then find "After update". Select "Event Procedure" and then click on the "..." button beside. This will open up the Visual Basic module behind the form, and label a "sub" procedure for you. In between the subs title and "end sub", copy in this and modify the names to suit your field name to the name of your "total field":

On Error Resume Next
If IsNull(Me.YourFieldName) Or Me.YourFieldName = 0 Then Exit Sub
Me.YourFieldName = Me.YourFieldName * -1

Close the module and click on our totals field. Same steps: Events tab, After update, "..." button to open VB and label a sub. Paste this in between and modify the names:

On Error Resume Next
If Me.YourFieldName < 0 Then
Me.YourCheckBoxName = -1
Else
Me.YourCheckBoxName = 0
End If

If your totals is a calculated field, you would have to refer to (example) a unit price field, if quantity * unit price = Total.

What this also does is if you already have a negative value in the field it will flip the check box to &quot;unchecked&quot; if you change your total value to a positive or zero. If you want this to &quot;stick&quot;, your check box would have to be &quot;bound&quot; to a Yes/No field in your table. If you just want to use it when you enter records, you don't have to bother. Gord
ghubbell@total.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top