Query criteria used for same subform in multiple parent forms

Sketchin

Registered User.
Local time
Today, 06:42
Joined
Dec 20, 2011
Messages
577
I have a sub form that shows me a companies history. This subform is used on 2 different Parent forms. The record source for the sub form uses a criteria that looks at a companyID field on the parent to determine which records to return. My question is how do I have the query criteria depend on which form is currently opened? The criteria would look something like this:

[Forms]![frmCompanyHistory]![txtCompanyID] OR [Forms]![frmCompany_Project_Details]![txtCompanyID]

If I open the form with this criteria, I will be asked for a value in txtcompanyID for whatever parent form is not open. How do I properly do this without making multiple queries that are almost identical?
 
Yes, I understand that. This subform is not for data entry. The main form will show the details of a project, where the subform will show what other projects that the company is involved with.
 
Doesn't it work with the 'Link Master Fields' and 'Link Child Fields' properties?
If not, can't you use the " Parent" in the criteria then?

Code:
Parent![txtCompanyID]
 
If you understand that, then why don't you implement it?
 
Well...It appears that I never fully understood linking ID fields. In my mind I was thinking it was only used for subforms that are for data entry (Think adding items to an invoice). This is going to save me a ton of headaches in the future!

Thanks for putting up with my silly questions!
 

Users who are viewing this thread

Back
Top Bottom