G
Guest
I have a form with a combobox of patients (cboPatients). Using the
AfterUpdate event of cboPatients, it opens a second datasheet form
(read-only) for that selected patient IF (and ONLY if) that patient had data
in the datasheet form ("frmContactsByStudy"); otherwise the datasheet form
closes with a message box of "no records" for that patients.
In the past I have used (on the second form): (where "ContactStudy" is a
control on the datasheet form "frmContactsByStudy":
Private Sub Form_Open(Cancel As Integer)
On Error GoTo YIKES
'
If IsNull(Me![ContactStudy]) Or Me![ContactStudy] = "" Then
MsgBox "No contact records for this study.", vbOKOnly +
vbInformation, "No Records"
Cancel = True
DoCmd.Close acForm, "frmContactsByStudy", acSaveNo
End If
'
'
Exit_YIKES:
Exit Sub
'
YIKES:
If Err = 2501 Or Err = 2427 Then
Resume Exit_YIKES
Else
MsgBox Err.Number & ": " & Err.Description
Resume Exit_YIKES
End If
'
End Sub
=================================================
This used to work, but now fails in Access 2000 under Win2000. Is it because
"frmContactsByStudy" is a datasheet? Or some other reason?
Thanks!
Philip Szlyk
(e-mail address removed)
AfterUpdate event of cboPatients, it opens a second datasheet form
(read-only) for that selected patient IF (and ONLY if) that patient had data
in the datasheet form ("frmContactsByStudy"); otherwise the datasheet form
closes with a message box of "no records" for that patients.
In the past I have used (on the second form): (where "ContactStudy" is a
control on the datasheet form "frmContactsByStudy":
Private Sub Form_Open(Cancel As Integer)
On Error GoTo YIKES
'
If IsNull(Me![ContactStudy]) Or Me![ContactStudy] = "" Then
MsgBox "No contact records for this study.", vbOKOnly +
vbInformation, "No Records"
Cancel = True
DoCmd.Close acForm, "frmContactsByStudy", acSaveNo
End If
'
'
Exit_YIKES:
Exit Sub
'
YIKES:
If Err = 2501 Or Err = 2427 Then
Resume Exit_YIKES
Else
MsgBox Err.Number & ": " & Err.Description
Resume Exit_YIKES
End If
'
End Sub
=================================================
This used to work, but now fails in Access 2000 under Win2000. Is it because
"frmContactsByStudy" is a datasheet? Or some other reason?
Thanks!
Philip Szlyk
(e-mail address removed)