Solved

Using Dlookup with multiple fields to display one field

Posted on 2013-10-30
13
332 Views
Last Modified: 2013-11-04
I have a Table [IEGDate] with 4 primary key fields; [Effective], [HHSize], [Frequency], [IncomeType] with a  non-primary key field [IncomeThreshold].

I also have a form [IEChild], with fields [HHSize], [HHIncome] and [Frequency].  I need to lookup these 3 fields in the [IEGDate] table and return the [IncomeType] on this form.  The [HHIncome] field would correspond with the [IncomeThreshold].  In summary, the fields [HHSize] and [Frequency] must match and the [HHIncome] must be equal to or less than the [IncomeThreshold] to display the [IncomeType].  If the [HHIncome] is greater than the [IncomeThreshold], display "No".

Can you assist?
0
Comment
Question by:softsupport
[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
  • 6
  • 6
13 Comments
 
LVL 31

Expert Comment

by:Helen Feddema
ID: 39612568
I think you would be much better off doing this filtering in a query used for the form's record source, or possibly a subform.  It is a lot easier to work with filters and calculations in the Query Designer, as opposed to the control source of a textbox on a form.
0
 

Author Comment

by:softsupport
ID: 39612646
I would like to use the DLookup feature, ( or some other lookup) to search the table and display results, if it is possible.
0
 
LVL 30

Expert Comment

by:hnasr
ID: 39612886
This looks up one field "Entity" in table "comma"  with condition of 2 fields Year and Case:

 DLookup("Entity", "comma", "[Year]='" & Me.Year & "' AND [Case]='" & Me.Case & "'")

"Using Dlookup with multiple fields to display one field"
Multiple fields go in the where condition.
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:softsupport
ID: 39613680
Thank you for the Dlookup example above, but I would like to lookup 3 fields, returning 1.
0
 
LVL 30

Expert Comment

by:hnasr
ID: 39615378
"Thank you for the Dlookup example above, but I would like to lookup 3 fields, returning 1. "

Do you mean if we have a table x(a, b, c, d)
a b c d
1 1 1 b
1 1 2 c
2 2 2 d

If you look for record with 1, 1, 1 do you expect to report back the value b?
Using a where clause will report the same result.

So what exactly you are looking for?

Talk as you would tell some one over the phone what to do to get the expected result.
0
 

Author Comment

by:softsupport
ID: 39616756
In a form [Family], I have 3 fields, [HSize], [HIncome], [Frequency]

In a table [IEG]I have 4 fields [HSize], [IncomeThreshold], [Frequency], [Type]

I would like the database to compare the fields in [Family] table to fields in [IEG] table.

[Family]![HSize] must equal [IEG]![HSize]
[Family]![Frequency] must equal [IEG]![Frequency]
[Family]![HIncome] must be less than or equal to [IEG]![IncomeThreshold]

If it meets all 3 criteria, display the [IEG]![Type], if not display N.


Hope this clarifies my request.
0
 
LVL 30

Assisted Solution

by:hnasr
hnasr earned 500 total points
ID: 39617999
Yes this is the same case, look for [IEG]![Type]

DLOOKUP ("[Type]", "IEG", " [IEG]![HSize]='" & [Family]![HSize] & "' AND [Frequency]='" & [Family]![Frequency] & "' AND  [IncomeThreshold] >='" & [Family]![HIncome] &"'")

Remove single quotes  if fields are numeric.
0
 

Author Comment

by:softsupport
ID: 39620563
Works perfectly, except

 "If it meets all 3 criteria, display the [IEG]![Type], if not display N."
Can I display on the [Family] form
0
 
LVL 30

Expert Comment

by:hnasr
ID: 39620642
Nz(DLOOKUP ("[Type]", "IEG", " [IEG]![HSize]='" & [Family]![HSize] & "' AND [Frequency]='" & [Family]![Frequency] & "' AND  [IncomeThreshold] >='" & [Family]![HIncome] &"'"),"N")
0
 

Author Comment

by:softsupport
ID: 39620662
And to show on family form?  Use unbound field?
0
 
LVL 30

Accepted Solution

by:
hnasr earned 500 total points
ID: 39620672
"And to show on family form?  Use unbound field? "

Yes, you may use it in proper place:

TxtBox1 = Nz(DLOOKUP ("[Type]", "IEG", " [IEG]![HSize]='" & [Family]![HSize] & "' AND [Frequency]='" & [Family]![Frequency] & "' AND  [IncomeThreshold] >='" & [Family]![HIncome] &"'"),"N")

Or you may set the control source for a TextBox as =Nz(DLOOKUP ("[Type]", "IEG", " [IEG]![HSize]='" & [Family]![HSize] & "' AND [Frequency]='" & [Family]![Frequency] & "' AND  [IncomeThreshold] >='" & [Family]![HIncome] &"'"),"N")
0
 

Author Closing Comment

by:softsupport
ID: 39622383
Thank you so very, very much!!!
0
 
LVL 30

Expert Comment

by:hnasr
ID: 39623226
Welcome!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

687 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