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
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