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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open to selected criteria in subform

Status
Not open for further replies.

Debbie37

Technical User
Feb 23, 2002
28
US
I have a form that I set the OnClick event to the following:

Private Sub Form_Click()
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmmainform"

stLinkCriteria = "[ReqID]=" & Me![ReqID]
'[ReqID] actually refers to a field name in the subform of frmMainForm
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub
However, I want the subform's (frmRequestSubform) field value (ReqID) set to equal the ReqID of the record I select in the first form. If I set the field's value to one in the Main Form [PatientID] it works fine, but when I change it to [ReqID], the subform, it opens empty even when I write the entire path: forms!frmMainForm!frmRequestsubform.Form![ReqID]. What am I doing wrong?
 
but when I change it to [ReqID], the subform, it opens empty even when I write the entire path:

I am unsure what you mean by this. From reading this, it seems like you are trying to say that when you change the ReqID in the Subform, the subform opens blank.

Could you clarify please...

James Goodman MCP
 
What I mean is when I change it to look for (match the value) the [ReqID] in the subform it open blank, like this:
Private Sub Form_Click()
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmmainform"

stLinkCriteria = "[ReqID]=" & Me![ReqID]
'the above matches criteria in the main form (frmMainForm)

stLinkCriteria = "[ReqID]=" & Forms!frmMainForm!
frmRequestSubform.Form![ReqID]
'when I change it to look at the value for [ReqID] it actually refers to a field name in the subform of frmMainForm, which is what I want

DoCmd.OpenForm stDocName, , , stLinkCriteria

The main form (tblPatient primary key PtID) collects patient demos (name, DOB, etc) while the subform (tblRequest, primary key ReqID) collects realease of information requests for each patient in the main form. So, I have my main form, and a patient lookup form that allows the user to type in a patient name which populates the list box on the same form. After selecting the patient in the list box (populated with search results) the AfterUpdate property opens a form listing each realease record for that selected patient. The last part of this is the OnClick event of that form opening the main form matching the [ReqID]in both the subform and the form listing the request records. I hope this helps. I so appreciate your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top