A
A Marano
I have a form frmPatientSelection with a command button cmdFindPatient, that
opens another form frmPatientEntry using the following code:
Dim TempFilter As String
TempFilter = "[MedicalRecordNum]=" & "'" & Me![txtMedicalRecordNum] &
"'"
DoCmd.OpenForm "frmR1EntryForm", , , TempFilter
where txtMedicalRecordNum is a TextBox that allows the user to enter a
patient's medical record number thereby selecting a patient in
frmPatientEntry.
In frmPatientEntry, I used the OnOpen event to test for whether a patient
with that medical record number actually exists and if not, cause the form
to not open and give an error message:
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "Please select a valid medical record number, blah, blah
blah."
Cancel = True
End If
This all works fine but my problem is this: I want to add another button
that allows the user to add a brand new patient. But any code I write to do
this runs into frmPatientEntry's OnOpen event which tests for the "no valid
record" condition. How can I somehow put code in the cmdAddNewPatient
button that bypasses frmPatientEntry's OnOpen event code?
Thanks in advance!
opens another form frmPatientEntry using the following code:
Dim TempFilter As String
TempFilter = "[MedicalRecordNum]=" & "'" & Me![txtMedicalRecordNum] &
"'"
DoCmd.OpenForm "frmR1EntryForm", , , TempFilter
where txtMedicalRecordNum is a TextBox that allows the user to enter a
patient's medical record number thereby selecting a patient in
frmPatientEntry.
In frmPatientEntry, I used the OnOpen event to test for whether a patient
with that medical record number actually exists and if not, cause the form
to not open and give an error message:
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "Please select a valid medical record number, blah, blah
blah."
Cancel = True
End If
This all works fine but my problem is this: I want to add another button
that allows the user to add a brand new patient. But any code I write to do
this runs into frmPatientEntry's OnOpen event which tests for the "no valid
record" condition. How can I somehow put code in the cmdAddNewPatient
button that bypasses frmPatientEntry's OnOpen event code?
Thanks in advance!