?
Solved

Using Dlookup with multiple fields to display one field

Posted on 2013-10-30
13
Medium Priority
?
353 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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 2000 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 2000 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

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…
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…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

777 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