Message box one time only

B

Bruce

I have a combo box on a form with four of the most common
possibilities written into the Row Source, and Limit to
List set to No. The user has three options: Type an
entry, select from the combo box list, or select and
modify. The combo box had been a text box before I added
the choices. Its After Update event was:
If Me.NewRecord = True Then
If MsgBox("Message text", vbYesNo) = vbYes Then
Me.txtNextField.SetFocus
Else: Forms!frmMain!fsubSubform.Form! _
chkYesNo.DefaultValue _ = Not Forms!frmMain! _
fsubSubform.Form!chkYesNo.DefaultValue
End If
End If

The message box was vbYesNo. Yes puts a check mark in a
field on a subform (actually, it toggles the field from
the default value). No leaves the box unchecked. It
works as intended. The problem with the combo box is that
if the user selects from the list, the message box pops
up. If the user then modifies the selection, the box pops
up again. If the user clicks Yes in both cases, it
toggles the check box back to the default. What I would
like is for the check box to appear once only. One thing
that occurs to me is that if the After Update event for
the combo box includes saving the record:
(DoCmd.RunCommand acCmdSaveRecord added after the second
End If) then it won't be a new record after selecting from
the combo box, and the message box won't reappear. This
seems to work, but the database is in use and I want to
make sure I am not creating unintended complications.
Related question: How can I remind users that they are
supposed to put an entry into the combo box? I don't want
to use the default Access error messag for a required
field, as it is meaningless to most users. The form opens
to a new record since that is the most common use of the
database, but it could also open to the last record if
that helps. Also, it opens with the focus set to the
combo box. The problem with a message box reminder that
is generated if the field is left blank is that if the
user intends to search the records or some other such
operation they will need to exit the combo box without
entering anything. They should not receive a reminder in
those cases. If the form opens to the last record, the
user will need to make a deliberate choice to enter a new
record, so maybe the false error messages won't occur. I
am just not at all sure how to proceed.
 

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

Top