K
Kurt
I have a subform (fsubPatients; in datasheet view) linked
to a main form (frmStudies). They are linked by StudyID.
When the user clicks on the "Withdraw Patient" button (on
the main form), I'd like to:
1) prompt him to select a patient/record in the subform
(in case he forgot) then
2) open frmPatients on the corresponding patient record
that was selected in the subform
My If statement for step 1 doesn't work. How do I check to
see that a record in the subform (in datasheet view) has
been selected?:
If IsNull(Me!fsubPatients.Form!PatientID) Then
'If no patient has been selected, exit sub
MsgBox "Select the patient you'd like to withdraw."
Exit Sub
My code for Step 2 works (it opens frmPatients on the
correct record), but it opens *only* that record and
prevents that user from navigating to other records. How
can I have frmPatients open to the matching record, but
still have other records accessible during the same
session?
Else
'This kind of works, but prevents the user from
'navigating to other records
MsgBox "Going to patient's record now . . ." & _
" " & Chr(13) & _
" " & Chr(13) & _
"Once there, check the 'Withdrawn' box next to
appropriate study listed in the Studies box."
stDocName = "frmPatients"
stLinkCriteria = "[PatientID]=" &
Me!fsubPatients.Form!PatientID
DoCmd.OpenForm stDocName, , , stLinkCriteria
---------------------------------------------------
Thanks!
Kurt (full OnClick code below if needed)
###
Private Sub cmdWithdraw_Click()
On Error GoTo Err_cmdWithdraw_Click
Dim stDocName As String
Dim stLinkCriteria As String
If IsNull(Me!fsubPatients.Form!PatientID) Then
'If no patient has been selected, exit sub
MsgBox "Select the patient you'd like to withdraw."
Exit Sub
Else
'This works
MsgBox "Going to patient's record now . . ." & Chr
(13) & _
" " & Chr(13) & _
"Once there, check the 'Withdrawn' box next to
appropriate study listed in the Studies box."
stDocName = "frmPatients"
stLinkCriteria = "[PatientID]=" & Me!
fsubPatients.Form!PatientID
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
Exit_cmdWithdraw_Click:
Exit Sub
Err_cmdWithdraw_Click:
MsgBox Err.Description
Resume Exit_cmdWithdraw_Click
End Sub
to a main form (frmStudies). They are linked by StudyID.
When the user clicks on the "Withdraw Patient" button (on
the main form), I'd like to:
1) prompt him to select a patient/record in the subform
(in case he forgot) then
2) open frmPatients on the corresponding patient record
that was selected in the subform
My If statement for step 1 doesn't work. How do I check to
see that a record in the subform (in datasheet view) has
been selected?:
If IsNull(Me!fsubPatients.Form!PatientID) Then
'If no patient has been selected, exit sub
MsgBox "Select the patient you'd like to withdraw."
Exit Sub
My code for Step 2 works (it opens frmPatients on the
correct record), but it opens *only* that record and
prevents that user from navigating to other records. How
can I have frmPatients open to the matching record, but
still have other records accessible during the same
session?
Else
'This kind of works, but prevents the user from
'navigating to other records
MsgBox "Going to patient's record now . . ." & _
" " & Chr(13) & _
" " & Chr(13) & _
"Once there, check the 'Withdrawn' box next to
appropriate study listed in the Studies box."
stDocName = "frmPatients"
stLinkCriteria = "[PatientID]=" &
Me!fsubPatients.Form!PatientID
DoCmd.OpenForm stDocName, , , stLinkCriteria
---------------------------------------------------
Thanks!
Kurt (full OnClick code below if needed)
###
Private Sub cmdWithdraw_Click()
On Error GoTo Err_cmdWithdraw_Click
Dim stDocName As String
Dim stLinkCriteria As String
If IsNull(Me!fsubPatients.Form!PatientID) Then
'If no patient has been selected, exit sub
MsgBox "Select the patient you'd like to withdraw."
Exit Sub
Else
'This works
MsgBox "Going to patient's record now . . ." & Chr
(13) & _
" " & Chr(13) & _
"Once there, check the 'Withdrawn' box next to
appropriate study listed in the Studies box."
stDocName = "frmPatients"
stLinkCriteria = "[PatientID]=" & Me!
fsubPatients.Form!PatientID
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
Exit_cmdWithdraw_Click:
Exit Sub
Err_cmdWithdraw_Click:
MsgBox Err.Description
Resume Exit_cmdWithdraw_Click
End Sub