Form Not Close If Statement Needed!

  • Thread starter Thread starter Dave Elliott
  • Start date Start date
D

Dave Elliott

On My form I have a Check Box True/False where if the Print button is
clicked it's value changes to 1, i.e. Printed
Default value of check box is neither true or false, so I guess it is False,
I did not set a Default and it cant be edited via the form.
Printed = 1 is in the On Click Event of the Print Check Command Button
If the check box value is not 1 and the control Customers is not null then
the form should not be able to close.
In other words if a payee has been chosen and the check has not been
printed, (Printed=1) then form cant close.
Control Customers is where you enter a payee, i.e. a person to print the
check to.
Tried different code, but could not make it work.

Thanks,

Dave
P.S. Thanks Fred
Could no make your solution work, sure it is my fault.
 
Dave said:
On My form I have a Check Box True/False where if the Print button is
clicked it's value changes to 1, i.e. Printed
Default value of check box is neither true or false, so I guess it is
False, I did not set a Default and it cant be edited via the form.
Printed = 1 is in the On Click Event of the Print Check Command
Button If the check box value is not 1 and the control Customers is
not null then the form should not be able to close.
In other words if a payee has been chosen and the check has not been
printed, (Printed=1) then form cant close.
Control Customers is where you enter a payee, i.e. a person to print
the check to.
Tried different code, but could not make it work.
True = -1 and false = 0 in Access and VB.
Check boxes do have default values.

Both examples below will execute if YourCheckBox is True. If there is the
vaguest chance that somebody else might work on my code I use "YourCheckBox
= True " format

IF YourCheckBox = True then
do something
end if

OR

If YourCheckbox then
do the same thing
End If
 
Dave

A form's Unload event happens before its Close event. A form can't
close if you cancel the Unload event, so I suggest this is where you
should validate your data. I think the code will look something like
this...

Private Sub Form_Unload(Cancel As Integer)
If Not IsNull(Me.Customers) And Not Me.Printed Then
MsgBox "Print the check"
Cancel = True
End If
End Sub
 
Back
Top