I managed to resolve this by also adding this code to the OnClick
event of a control (which shows the person's names) in each of the
continuous subforms:
Me.Parent!txtPersonID = Me![PersonID]
(I also kept this in the OnCurrent event of both subforms.)
Everything seems to be performing as desired.
But I have a related issue, which I think can be overcome despite not
being able to control the order which Access loads the two subforms.
I have a search form (fsubSearch) with a listbox to search people and
hospitals. Column 0 of the listbox shows the person (PersonID) and
column 1 shows the hospital (HospitalID). Column 1 is the bound
column, so when the user selects an item, it finds the record with the
matching HospitalID and pulls it up on frmHospital. (frmSearch and
frmHospital are actually subforms on frmMain).
Like so:
###
Dim sbfrm As Form
' set focus to main form
Forms!frmMain.SetFocus
With Forms!frmMain!frmHospital
.SetFocus
Set sbfrm = .Form
End With
' find the desired record
With sbfrm.RecordsetClone
.FindFirst "[PracticeID]= " & Me.lstResults.Column(1)
If Not .NoMatch Then sbfrm.Bookmark = .Bookmark
End With
###
But how can I capture the values of *both* Column 0 and Column 1. This
way, it can call up the matching Hospital, and *also* select the
matching person (in either fsubDoctors or fsubNurses), and show that
person's details in fsubPersonDetails. If selecting the matching
record in fsubDoctors and fubNurses is too tricky, I can just populate
txtPersonID (with the PersonID from Column 0) on frmHospitals, and
fsubPersonDetails should update automatically.
I also need to handle the possibility that some hospitals many not
have any people (i.e., PersonID is Null), in which case txtPersonID
should be null (and hopefully fsubPersonDetails will default to a
newrecord). I suspect some sort of If statement could handle this:
If IsNull(lstResults.Column(0)) Then ' there are no people in this
hospital
Forms!frmMain!frmHospitals.Form!txtPersonID.Value = ""
Else
...
###
Thank you for any pointers.
|