F
Fred Urquhart via AccessMonster.com
Access 2003
Patient database
My main form opens up to a new record so that the form is blank.
I have a combo box on my main form that works off of a query. The query
brings up Patient Name, Patient ID, SSN, Medical Record number, etc., so you
can pick the patient you want.
I want the record selected in the combo box (PatientID) to pull up the
corresponding PatientID from the Patient Table and open it up on the form. So,
in the After Update event of the combo box I have the following code running:
Sub SelectPatient_AfterUpdate()
Dim rst As Recordset
Dim stPatientID As String
Set rst = Me.RecordsetClone
stPatientID = Str(Me!PatientID)
rst.FindFirst "PatientID = " & stPatientID
If rst.NoMatch Then
MsgBox "Record not found"
Else
Me.Bookmark = rst.Bookmark
End If rst.Close
End Sub
I set a watch on PatientID and stPatientID. I'm thinking that the code will
pull in the PatientID from the recordset that is the result of the query.
I think my problem is that I do not know how to grab the PatientID from the
recordset and plug it into a variable, then pick up the variable to pull up
that record from the underlying Patient Table.
My problem is that the above code does not pull in the PatientID from the
record selected in the combo box. It pulls up a completely different
PatientID and then compares it to the PatientID on the form which is blank
(new record) and then I error out on the Null from the blank field on the
form.
I think I have several problems going on but I can't seem to get it. I am not
sure where the problem lies.
Thanks
Fred
Patient database
My main form opens up to a new record so that the form is blank.
I have a combo box on my main form that works off of a query. The query
brings up Patient Name, Patient ID, SSN, Medical Record number, etc., so you
can pick the patient you want.
I want the record selected in the combo box (PatientID) to pull up the
corresponding PatientID from the Patient Table and open it up on the form. So,
in the After Update event of the combo box I have the following code running:
Sub SelectPatient_AfterUpdate()
Dim rst As Recordset
Dim stPatientID As String
Set rst = Me.RecordsetClone
stPatientID = Str(Me!PatientID)
rst.FindFirst "PatientID = " & stPatientID
If rst.NoMatch Then
MsgBox "Record not found"
Else
Me.Bookmark = rst.Bookmark
End If rst.Close
End Sub
I set a watch on PatientID and stPatientID. I'm thinking that the code will
pull in the PatientID from the recordset that is the result of the query.
I think my problem is that I do not know how to grab the PatientID from the
recordset and plug it into a variable, then pick up the variable to pull up
that record from the underlying Patient Table.
My problem is that the above code does not pull in the PatientID from the
record selected in the combo box. It pulls up a completely different
PatientID and then compares it to the PatientID on the form which is blank
(new record) and then I error out on the Null from the blank field on the
form.
I think I have several problems going on but I can't seem to get it. I am not
sure where the problem lies.
Thanks
Fred