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

If check box is checked double the amount entered into table 1

Status
Not open for further replies.

jbaughman

Technical User
Jan 3, 2013
7
US
I am working on a database that tracks printing press production and waste.

To calculate for duplex printing, I want to include a check box on the form that when the box is checked it will double the job page amount entered into the table and on the total shown at the bottom of the form.

This is probably pretty easy, but for some reason, I can't wrap my head around the logic or coding needed.

Any help will be much appreciated.

Thanks,
Jeff
 
Code:
Private Sub isDuplex_BeforeUpdate(Cancel As Integer)
  If Trim(Me.jobPageAmount & " ") = "" Then
    'Need to have the job page amount filled in
    MsgBox "Must fill in the job page amount first"
    Cancel = True
    Me.isDuplex.Undo
  Else
    'Handle checking
    If isDuplex Then
      Me.jobPageAmount = 2 * Me.jobPageAmount
    'Handle unchecking
    Else
      Me.jobPageAmount = 0.5 * Me.jobPageAmount
    End If
  End If
End Sub
 


Thanks MajP. This works, but the only problem I had is when it pops up with the msgbox to fill in the job page amount first, it doesn't uncheck the isDuplex box.

It's somewhere in this code:

If Trim(Me.jobPageAmount & " ") = "" Then
'Need to have the job page amount filled in
MsgBox "Must fill in the job page amount first"
Cancel = True
Me.isDuplex.Undo
Else

The Me.isDuplex.Undo is not unchecking it for some reason.

Thank you for the help!!!

Jeff
 
I got it.

I removed the Me.isDuplex.Undo line altogether.
The Cancel action does it already.

Thank you for your help!!!
 
I will have to think about that one. The way I set it up I have to have that line in or it does not work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top