Query criteria used for same subform in multiple parent forms (1 Viewer)

Sketchin

Registered User.
Local time
Today, 04:27
Joined
Dec 20, 2011
Messages
575
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?
 

Sketchin

Registered User.
Local time
Today, 04:27
Joined
Dec 20, 2011
Messages
575
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.
 

JHB

Have been here a while
Local time
Today, 12:27
Joined
Jun 17, 2012
Messages
7,732
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]
 

plog

Banishment Pending
Local time
Today, 06:27
Joined
May 11, 2011
Messages
11,611
If you understand that, then why don't you implement it?
 

Sketchin

Registered User.
Local time
Today, 04:27
Joined
Dec 20, 2011
Messages
575
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

Top Bottom