Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

3 linked forms record navigation problem.. 1

Status
Not open for further replies.

MrPiccolo

Technical User
Mar 29, 2004
15
GB
I've looked at the FAQ solutions but have not found a suitable answer for the following problem. please help!
I have 2 tables;
table 1. "Patients"
patientID (Pk)
other fields..

table 2. "Visits" 'shows visit data about each patient'
VisitID (Pk)
PatientID 'long integer, linked to "Patients" Table in a one-to-many relationship..
other fields..

In the database there are 3 key Forms;
#1) VisitByPatientOrder 'type=mainform linked to the Patients Table.

#2) VisitDetailsSubform 'type=subform of table #1) which is viewed as an embedded datasheet; and shows key fields drawn from a SQL query based on both Patients and Visits Tables

#3) Visits 'type=mainform linked solely to the Visits table; used for adding a NEW visits data for a patient OR editing a current Visit's data.

On the form VisitByPatientOrder
there is a commandbutton in the form footer, which has the following code in the on_click event procedure:-

Private Sub MatchPatientId_cmb_Click()
On Error GoTo Err_MatchPatientId_cmb_Click

Dim stDocName As String
Dim stLinkCriteria As String
'opens the visits form based on the link field "VisitID" in the "VisitByPatientOrder" subform.

DoCmd.OpenForm "visits", , , "[visits]![visitid]=forms![VisitsByPatientOrder]![VisitDetailsSubform].form![visitid]"
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_MatchPatientId_cmb_Click:
Exit Sub

Err_MatchPatientId_cmb_Click:
MsgBox Err.Description
Resume Exit_MatchPatientId_cmb_Click

End Sub

This button is meant to open the "Visits" Form and automatically display visit data for the last visitID selected in the subform "VisitDetailsSubform"; so for example if a patient has 3 visits (visitIDs of 3,7,11) and i've selected visitID 11 on the subform, then the Visits Form should open at record 11.
However on clicking the button there appears a MsgBox which says;
Enter Parameter Value
forms!visitsByPatientOrder!VisitDetailsSubform

This box actually appears twice and can be only resolved by entering 2 succesive values.

On opening the Visits Form from this command_button i want to be able to edit the pre-seleceted VisitID record OR enter a new visit for the current patient displayed in the main form "VisitByPatientOrder".
Where are the errors in this scenario?
many Thanks
MrPiccolo
 
Hi

Try

DoCmd.OpenForm "visits", , , "[visitid]=" & forms![VisitsByPatientOrder]![VisitDetailsSubform].form![visitid]

or if VistId is a string


DoCmd.OpenForm "visits", , , "[visitid]='" & forms![VisitsByPatientOrder]![VisitDetailsSubform].form![visitid] & "'"



Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi Ken,
I've tried both code lines but both return the following error code;

Microsoft Access can't find the field 'VisitDetailsSubform' referred to in your expression.

Any ideas?

MrPiccolo
 
Hi

Only that you check the name of the subform CONTROL, you have the form not me, so I cannot do it, I simply used the names you gave.

As I say you need to use the name of the subform CONTROL, not the name of the form which is embedded in that control, although they may of course be the same

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top