Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Linking subform, advice

Posted on 2013-01-02
4
Medium Priority
?
268 Views
Last Modified: 2013-01-02
Experts, I am modifying my form / subform setup.  I use to have Parent and sub linked by [tblLetterOfCredit].[EndUserID]. Now I need to show records based on more than only the [tblLetterOfCredit].[EndUserID]. The solution I thought of was to put  forms![End User Details].EndUserID for each field's criteria.  It works but maybe this method is  not efficient.  I dont know if I should  use an on Load event or some other event instead.  

Below is the mofied query sql I switched to (notice the Forms! criteria).  I previously used tblLetterOfCredit as the record source instead of simply linking parent and sub by EnduserID between the two tables:

let me know of any suggestions. (again my use of Forms!...does work fine but might not be most efficient or advisable).  I seem to remember that good database developers shy away from the use of Forms!  but what do i know.

SELECT
tblLetterOfCredit.LetterOfCreditID, tblLetterOfCredit.EndUserID, tblLetterOfCredit.UltimateBeneficiary, tblLetterOfCredit.Applicant,
FROM
tblLetterOfCredit
WHERE
(((tblLetterOfCredit.EndUserID)=forms![End User Details].EndUserID))
Or (((tblLetterOfCredit.UltimateBeneficiary)=forms![End User Details].EndUserID))
Or (((tblLetterOfCredit.Applicant)=forms![End User Details].EndUserID)));
0
Comment
Question by:pdvsa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Author Comment

by:pdvsa
ID: 38738708
here is the setup I have:  
TabbedSubform
0
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 38738818
I don't see anything wrong with your approach.

Since your criteria includes ORs, you're not going to be able to use Master-Child links on those fields, and will have to use form references (as you are already doing) instead.
0
 

Author Closing Comment

by:pdvsa
ID: 38738860
thank you Miriam.  I feel better now.  thanks again.
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38738866
Another option is to use TempVars which adds flexibility if you need the parameters of your query to be dependent on more than one form or report since the form object is not hardcoded in the query.  In your code you would add something like this:
TempVars("UserID") = Me.EndUserID

Then you query would be:
SELECT
LetterOfCreditID, EndUserID, UltimateBeneficiary, Applicant
FROM
tblLetterOfCredit
WHERE
EndUserID = TempVars!UserID
Or UltimateBeneficiary = TempVars!UserID
Or Applicant = TempVars!UserID;
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question