Full Version: Dynamic subform based on Query
UtterAccess Forums > Microsoft® Access > Access Forms
cedtech23
I have a form called frmPatientLookup
that query a table called tblPatientDemo based on 1-4 critrias
LastName,FirstName,DOB,Gender.
The results populate to a form called frmPatientLookupResults that pops up once I click on
command Button cmdFind
Currently the frmPatientLookupResults appears in a seperate window.
Is it possible to position that form to appear in the frmPatientLookup??
If so How??
Jack Cowley
Make a form based on the query then add this form a subform of your search form. Requery the subform from the command button that now runs the query. You do not need to run the query, just make your selections then requery the subform.
e.SubformControlName.Form.Requery
hth,
Jack
cedtech23
I based a subform called frmPatientLookupResults on a Query
And placed it in a main Form called frmPatientLookup
a command button on the Main form called cmdFind
with the following code
CODE
Private Sub cmdFind_Click()
DoCmd.OpenForm "frmPatientLookupResults"
Me!frmPatientLookupResults.Form.Requery
End Sub

Oknow the query works because DoCmd.OpenForm "frmPatientLookupResults"
return the correct results in a separte window.
But the same form as a subform only shows first patient of the table.
Any ideas what went wrong?
Jack Cowley
Remove any code in the Master/Child links of the subform then use this code in your command button.
Private Sub cmdFind_Click()
Me!frmPatientLookupResults.Form.Requery
End Sub
Oassume you have added 'frmPatientLookupResults' to form 'frmPatientLookup'. I have tried this and it works.
Jack
cedtech23
Thank You that worked great. I have another question as it relates to the subform.
Is it possible that my result that appear in the subform can be links
that open a form called frmPatientDemographics that would populate with
that Patients info
Example: My search brings up a patient called John Doe
when I click on his name it pops up the frmPatientDemographics
with all his info
Jack Cowley
You can do that. In the Double Click event of the LastName control in the subform:
oCmd.OpenForm "frmPatientDemographics", , , "[PatientID] = " & Me.PatientID
Jack
cedtech23
Jack,
That is the ,,, all about? I understand the rest of the statement but not that part
Jack Cowley
Search Access help for OpenForm to get the details about the arguments that are part of the OpenForm method...
th,
Jack
cedtech23
by the way it worked great I just want to know why for my knowledge
cedtech23
OK thanks again for the help
Jack Cowley
You are welcome!
ack
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.