Kamis, 07 Juli 2011

[MS_AccessPros] Synchronizing a Form and Sub-Form (Access 2003 or 7)

 

I apologize in advance for the length of this message. I've been trying to get it work for a bit.

Functionality Needed
I need a form that will give me the ability to select a RunID; the form should have a sub-form that displays selected columns for all table2 records with TripID that also have a table1.RunID equal to the selected (from the combo on the form) RunID.

Current Status
I have the form working.
I have the sub-form working.
Currently, the form and sub-form are operating independently. I can select the RunID. The sub-form is displaying all records as there are no criteria being passed to the sub-form.
What I don't know how to do is synchronize the sub-form query results for the combo box selected RunID from the form.
I've found all Table 1 TripIDs with the same RunID by creating a query using the Query Design tool, and joining Table 2 to Table 1 by TripId and using a hard-coded RunID as a query criterion.

Background Info
Table 1 (tblCurrentRunsWithTripsFromXMLTransform)
RunID – Number data type
TripID - Number data type
Table2 (tblCurrentOrcaXMLTrip)
TripID - Number data type
TripName – Text data type
PeakFlag – Text data type
PeakFare – Text data type
Relationship
Each Table1.RunID will have one or more Table2.TripIDs (not defined in Relationships).
Each Table2.TripIDs has only one Table1TripID (defined in Relationships)
The form contains only one Combo box that is populated by calling the qryCurrentDistinctRunsFromXMLTransform query.
SELECT [qryCurrentDistinctRunsFromXMLTransform].[RunId] FROM qryCurrentDistinctRunsFromXMLTransform ORDER BY [RunId];
The qryCurrentDistinctRunsFromXMLTransform query looks like this.
SELECT DISTINCT tblCurrentRunsWithTripsFromXMLTransform.RunId
FROM tblCurrentRunsWithTripsFromXMLTransform
ORDER BY tblCurrentRunsWithTripsFromXMLTransform.RunId;
The query that populates the sub-form is qryDisplayTripInfo
SELECT tblCurrentOrcaXMLTrip.TripId, tblCurrentOrcaXMLTrip.TripName, tblCurrentOrcaXMLTrip.PeakFlag, tblCurrentOrcaXMLTrip.PeakFare
FROM tblCurrentOrcaXMLTrip;

__._,_.___
.

__,_._,___

Tidak ada komentar:

Posting Komentar