Close Button

S

Simon

I have the followiung code on a close button, What i want to do the
close buttone to do is that it will only close if 'Hot Tub Order' Or
'Chemical order' YES/NO Tick button is clicked. If one of them is not
clicked i want it to a message to tell me and for the form not to
close.

My code brings up the message if box is not ticked but it still closes
the form

Can any one help

Private Sub cmdCLose_Click()

If Me.ChemicalOrder.Value = False And Me.HotTubOrder.Value = False Then
MsgBox "Please Select Chemical or Hot Tub Order", vbExclamationm

End If


On Error GoTo Err_Command184_Click


DoCmd.Close

Exit_Command184_Click:
Exit Sub

Err_Command184_Click:
MsgBox Err.Description
Resume Exit_Command184_Click


End Sub
 
K

Ken Snell \(MVP\)

The code to close the form should be in the Else subblock for the If..Then
block:

Private Sub cmdCLose_Click()
On Error GoTo Err_Command184_Click
If Me.ChemicalOrder.Value = False And Me.HotTubOrder.Value = False Then
MsgBox "Please Select Chemical or Hot Tub Order", vbExclamationm
Else
DoCmd.Close
End If

Exit_Command184_Click:
Exit Sub

Err_Command184_Click:
MsgBox Err.Description
Resume Exit_Command184_Click

End Sub
 

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

Similar Threads


Top