H
HeislerKurt
I have a form which pops up when the user clicks on a button.
The form is used to enter patient information (name, etc.). When the
user exits the last name field, code checks to see if a person with
the same first & last name is already in the table. If it finds a
possible duplicate, a message pops up and gives the user the option of
continuing (Yes or No).
If he clicks No, the message goes away and he's back to the form. How
can I have this form close automatically when he clicks No? If I
put ...
DoCmd.Close acForm, "frmNewPatient"
.... in with the LastName Exit code, I get:
"Run-time error 2585: This action can't be carried out while
processing a form or report event."
.... because the form's code is still processing. How can get around this
and get the form to close?
Thank you.
Relevant code below:
###
Pt_LName_Exit
....
If MsgBox(sMsg, vbYesNo + vbDefaultButton2, "Possible Duplicate ")
<> vbYes Then
Cancel = True
Me.Undo
' this is the logical time to close the form, but it causes the
2585 error
' DoCmd.Close acForm, "frmNewPatient"
End If
....
End Sub
The form is used to enter patient information (name, etc.). When the
user exits the last name field, code checks to see if a person with
the same first & last name is already in the table. If it finds a
possible duplicate, a message pops up and gives the user the option of
continuing (Yes or No).
If he clicks No, the message goes away and he's back to the form. How
can I have this form close automatically when he clicks No? If I
put ...
DoCmd.Close acForm, "frmNewPatient"
.... in with the LastName Exit code, I get:
"Run-time error 2585: This action can't be carried out while
processing a form or report event."
.... because the form's code is still processing. How can get around this
and get the form to close?
Thank you.
Relevant code below:
###
Pt_LName_Exit
....
If MsgBox(sMsg, vbYesNo + vbDefaultButton2, "Possible Duplicate ")
<> vbYes Then
Cancel = True
Me.Undo
' this is the logical time to close the form, but it causes the
2585 error
' DoCmd.Close acForm, "frmNewPatient"
End If
....
End Sub