Solved

Linking subform, advice

Posted on 2013-01-02
4
261 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
  • 2
4 Comments
 

Author Comment

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

Accepted Solution

by:
mbizup earned 500 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now