MsgBox and CheckBox Field

  • Thread starter Thread starter kateri4482
  • Start date Start date
K

kateri4482

I have a check box field (called Archive), and when someone clicks on it, I
want a message to pop up that says "Are you sure?" and then if the answer is
yes, a check mark will be placed into the field, and if they say no, there
will be no check mark and nothing happens (it remains blank by default).
Also, if they say yes, I want the field called ArchiveDate to be required (so
they will need to enter a date). How do I say all of this? And will this go
into the BeforeUpdate expression?

Thanks!
 
well, you can screen for the archive decision in the checkbox control's
BeforeUpdate event, but you'll probably need to check the associated date
control in the *form's* BeforeUpdate event. for the checkbox BeforeUpdate
event, something like

If Msgbox("Are you sure?", _
vbYesNo + vbDefaultButton2) = vbNo Then
Cancel = True
Me!Archive.Undo
End If

setting the No button as the default will require the user to actually
select Yes to archive the record; if the user just hits Enter when the
msgbox pops up without reading it - as users are prone to doing - nothing
happens, the Archive field is not changed.

and perhaps a nudge to the user, with the following code in the checkbox
control's AfterUpdate event, as

If Me!Archive = True Then Me!ArchiveDate.SetFocus

for the form's BeforeUpdate event, something like

If Me!Archive = True And IsNull(Me!ArchiveDate) Then
Cancel = True
Me!ArchiveDate.SetFocus
MsgBox "Enter the archive date, please."
End If

hth
 
Perfect. Thank you.

tina said:
well, you can screen for the archive decision in the checkbox control's
BeforeUpdate event, but you'll probably need to check the associated date
control in the *form's* BeforeUpdate event. for the checkbox BeforeUpdate
event, something like

If Msgbox("Are you sure?", _
vbYesNo + vbDefaultButton2) = vbNo Then
Cancel = True
Me!Archive.Undo
End If

setting the No button as the default will require the user to actually
select Yes to archive the record; if the user just hits Enter when the
msgbox pops up without reading it - as users are prone to doing - nothing
happens, the Archive field is not changed.

and perhaps a nudge to the user, with the following code in the checkbox
control's AfterUpdate event, as

If Me!Archive = True Then Me!ArchiveDate.SetFocus

for the form's BeforeUpdate event, something like

If Me!Archive = True And IsNull(Me!ArchiveDate) Then
Cancel = True
Me!ArchiveDate.SetFocus
MsgBox "Enter the archive date, please."
End If

hth
 
Back
Top