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

Creating Check Box

Status
Not open for further replies.

ChrisBair

Technical User
Mar 17, 2004
32
US
Trying to place a Sales order on hold(OrderOnHold Field)
with a check box. Want it to warn before placing on hold, then a warning to take off hold.
Private Sub Order_On_Hold_Click()

If MsgBox("Do you want to close out this Sales Order?", vbYesNo, "Close out SO?") = vbYes Then
'Update the OrderOnHold Flag and save the record


End If

'We want to Take off hold
If MsgBox("Are you sure you want take order off hold?", vbYesNo, "Take off Hold?") = vbYes Then

End If

End Sub

Will not work, any suggestions
 
Hi!

Assuming your check box is bound to a Yes/No field, first, I'd use the after update of the control in stead of the click event, then I'd check the value of it, perhaps something like this:

[tt]if me!chkOrderOnHold.Value then
If MsgBox("Do you want to close out this Sales Order?" _
, vbYesNo, "Close out SO?") = vbYes Then
' save record
docmd.runcommand accmdsaverecord
else
' toggle the checkbox back again
me!chkOrderOnHold.Value=not me!chkOrderOnHold.Value
end if
else
If MsgBox("Are you sure you want take order off hold?" _
, vbYesNo, "Take off Hold?") = vbNo Then
' toggle the checkbox back again
me!chkOrderOnHold.Value=not me!chkOrderOnHold.Value
end if
end if[/tt]

- typed not tested, replace chkOrderOnHold with the name of your checkboxcontrol

btw - see you're a relatively new member, welcome to Tek-Tips! Here's a little faq on how to get the most out of the membership faq181-2886, Good Luck!

Roy-Vidar
 
When the "Click" event is raised on a check box, the state of the check box has already changed from what it was to the opposite value.

You need to test the value of the check box control and, based on that, decide which question to ask. You also need to be aware that setting the value of a check box in code will raise the Click event again so you need to provide a trap to get out of the routine if it was called recursively.
[blue][tt]
Private Sub Order_On_Hold_Click()
Static ProcessingClick As Boolean
If ProcessingClick Then Exit Sub
ProcessingClick = TRUE

If Order_On_Hold.Value = TRUE Then
If MsgBox("Do you want to close out this Sales Order?", _
vbYesNo, "Close out SO?") = vbYes Then
'Update the OrderOnHold Flag and save the record
Else
Order_On_Hold.Value = FALSE
End If
Else
'We want to Take off hold
If MsgBox("Are you sure you want take order off hold?", _
vbYesNo, "Take off Hold?") = vbYes Then
' Remove HOLD Status from Order
Else
Order_On_Hold.Value = FALSE
End If
End If
ProcessingClick = FALSE
End Sub
[/tt][/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top