T
tlyczko
I have a form with four controls:
cboTopic (choose a topic)
dtmTrainingDate (text, date entry)
mslbxTest (multiple select box, choose names)
cmdUpdateDatabase (button, clicking processes all the form code to
review data and update the database)
When the user clicks cmdUpdateDatabase, the evaluation of the first
three controls occurs.
For example,
If IsNull(Me.cboTopic.Value) Or Me.cboTopic.Value = 0 Then
Call MsgBox("Please select a topic from the drop-down list.",
vbExclamation, "Select Topic")
Me.cboTopic.SetFocus
End If
If Me.dtmTrainingDate.Value > Now() Then
Call MsgBox("You've entered a date or year in the future. Please
enter a valid training date.", vbExclamation, "Enter Date")
Me.dtmTrainingDate.SetFocus
End If
If Me.mslbxTest.ItemsSelected.Count = 0 Then
Call MsgBox("Please make a selection from the list.",
vbExclamation, "Select Names")
Me.mslbxTest.SetFocus
End If
The problem is that the message boxes appear, one by one, but the
onClick event code does not pause until later, it keeps processing, it
doesn't let the user go back to the form.
I want the onClick code to pause immediately if any of these conditions
occur, and send the user back to the form to fix it.
I tried putting 'On Error Resume Next' before the SetFocus lines, but
that does not work.
How do I make the Access code stop to permit the user to fix his/her
mistake, then continue processing??
Thank you,
tom
cboTopic (choose a topic)
dtmTrainingDate (text, date entry)
mslbxTest (multiple select box, choose names)
cmdUpdateDatabase (button, clicking processes all the form code to
review data and update the database)
When the user clicks cmdUpdateDatabase, the evaluation of the first
three controls occurs.
For example,
If IsNull(Me.cboTopic.Value) Or Me.cboTopic.Value = 0 Then
Call MsgBox("Please select a topic from the drop-down list.",
vbExclamation, "Select Topic")
Me.cboTopic.SetFocus
End If
If Me.dtmTrainingDate.Value > Now() Then
Call MsgBox("You've entered a date or year in the future. Please
enter a valid training date.", vbExclamation, "Enter Date")
Me.dtmTrainingDate.SetFocus
End If
If Me.mslbxTest.ItemsSelected.Count = 0 Then
Call MsgBox("Please make a selection from the list.",
vbExclamation, "Select Names")
Me.mslbxTest.SetFocus
End If
The problem is that the message boxes appear, one by one, but the
onClick event code does not pause until later, it keeps processing, it
doesn't let the user go back to the form.
I want the onClick code to pause immediately if any of these conditions
occur, and send the user back to the form to fix it.
I tried putting 'On Error Resume Next' before the SetFocus lines, but
that does not work.
How do I make the Access code stop to permit the user to fix his/her
mistake, then continue processing??
Thank you,
