Make a number to a negative number

  • Thread starter Thread starter katja.bostrom
  • Start date Start date
K

katja.bostrom

I have a form with two checkboxes M and T. M is for outgoing products
and T is for incoming products. In the same form there is a subform
were you add the products that is incoming and outgoing and the amount
of in/out coming. It it possible to do the following:

If I check the M checkbox can I get the amount to be negative in the
subform?
 
Hi Katja

Set this code on the AfterUpdate of checkbox M

Private Sub M_AfterUpdate()
If (Forms!MainForm!M = -1) Then
Forms!MainForm!SubForm.Form!AmountField =
Forms!MainForm!SubForm.Form!AmountField -
(Forms!MainForm!SubForm.Form!AmountField * 2)
End If
End Sub

Change . . . . .
MainForm
SubForm
AmountField
To the correct names and this should work

and I have assumed the checkbox M is simply called "M" (change if nes)


Oh and you may want to look at an option group rather then 2 check boxes -
assuming that items are always either incomeing or outgoing - then use Case I
and Case 2, etc. (easier for the user and easier for coding) - Just a thought

Hope this helps
 
Set the controlsource of a textbox in the subform's footer to:

=Count([Field Name]) * -1

or:

=Sum([Field Name]) * -1

depending upan if you want to count the number of checkboxes or total the
value in the textboxes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top