Solved

Linking subform, advice

Posted on 2013-01-02
4
267 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 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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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…

617 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