Solved

how to dlookup up for multiple criteria

Posted on 2013-06-29
11
432 Views
Last Modified: 2013-07-01
hi guys, i want to write a dlookup line or whichever other method i'm ok also - just how do i look up with the criteria that:

CategoryDescription = 1 AND CategoryAcronym = H
AND
CategoryDescription = 2 AND CategoryAcronym = ACT
AND
CategoryDescription = 3 AND CategoryAcronym = E

to get CodeID = 1 as per the below image? thanks guys!!
dlookup
0
Comment
Question by:developingprogrammer
[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
11 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 39286599
What are you trying to look up?

Do you mean that all three pairs of values must exist  to return a value or do you mean that one (or more) of the three pairs must exist?
0
 

Author Comment

by:developingprogrammer
ID: 39286618
all 3 pairs sir. = )
0
 
LVL 40

Expert Comment

by:als315
ID: 39286630
Dlookup can return you only one record. You like to analyze set of records, so you should make some concatenation of your data before you will be able get ID from dlookup.
In your case you can sum numeric fields as bit 2^CategoryDescription and concatenate sorted text fileds and get following result:
1   14       ACT-E-H
2   14       ACT-E-R

Now you can make dlookup
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

Author Comment

by:developingprogrammer
ID: 39286668
what would be the best way to make a concatenated field?

Table --> Select Query --> Dlookup from query?

sorry to trouble als315 but do you think you could show me how you'd do it using this database i just attached here?

must i have fixed columns for the concatenation or can i do it in a way such that it kinda concatenates like a crosstab query? a crosstab query with the ability to have more than 1 column header cause currently that's the crosstab query's limitation right?

thanks als315!! = ))
DMS-Cerebro---SSB-Recon.mdb
0
 

Author Comment

by:developingprogrammer
ID: 39286708
Oh what I meant by the fixed column headers thing is - can the concatenation be done in a way that can dynamically increase should I add more categories? E.g. Now I have cat 1, cat 2 and cat 3. What if I add one more cat 4 just like in the DB I submitted - H-ACT-E-Z versus C-ACT-E (4 categories vs 3 categories)
0
 
LVL 40

Accepted Solution

by:
als315 earned 500 total points
ID: 39286736
You can concatenate text strings with mattewspatrick's function:
A_2380
or you can add numeric field to your table (perfAcronymDefinition) with degrees of 2 and simply sum these values.
With simple function (see module1, comparebit function) you can make bit compare of this sum.
Look at query1
In your sample bit sum of CategoryDescription (CD field) for Id 1 will be14 (1-2-3 = 2+4+8) and for ID 2 - 30 (1-2-3-4 = 2+4+8+16). Both contain bits 2,4,8, so result of compare will be true for both cases.
Second parameter (CB field) will be 26 (ACT-E-H = 2+8+16) for ID 1 and 15 for ID 2 (ACT-C-E-Z = 2+4+8+1).
DMS-Cerebro---SSB-Recon.mdb
0
 

Author Comment

by:developingprogrammer
ID: 39287717
whao als315, that is some seriously amazing logic!!!!

i spent some time to understand - got 3 questions.

1) what if i have 10,000 AcronymDefinition rows? then the CategoryBit of 1,2,4,8,16,32 will very very quickly run out right? please correct my maths if its wrong, but using a 4 byte unsigned long, i would only have 8 + 8 + 8 + 8 = 32 AcronymDefintion rows right?

2) long integer is a signed number. if i really do have only 32 AcronymDefinitions, then i will have to key in negative numbers for anything above 32k right?

3) so assuming i stay within the limits of 32 rows, then how i would use the solution you gave me is that i will get an Acronym from the user (say they key in ACT), then i'll use dlookup to get its CategoryBit, and then repeat the steps for H, E and once i've gotten the 3 CategoryBits for the Acronyms then i'll sum them up and use a dlookup from the query1 select query you gave me it that correct?

thanks so much once again als315 for your help!!!! = ))
0
 
LVL 40

Assisted Solution

by:als315
als315 earned 500 total points
ID: 39287814
1. Yes, you need some alternate way for this case. You may use some predefined AcronimDefinition groups. I think it is also possible.
2. Long integer could be from 2,147,483,648 to +2,147,483,647:
http://office.microsoft.com/en-us/access-help/set-the-field-size-HA010274716.aspx#BM2
really max is 2^30, because CLNG(2^31) will give overflow. You can use HEX text strings or any other text encoding, but logic will not be so simple.
3. look at sample DB (Form1)
DMS-Cerebro---SSB-Recon.mdb
0
 

Author Closing Comment

by:developingprogrammer
ID: 39289790
thanks als315!! i superbly superbly superbly like you solution!! but unfortunately i had too many categories and the UDF you suggested by matthewspatrick was a lot easier so i went by that route. but your solutions always blow me away in amazement. always left wonder how in the world you thought about such a cool idea!! = ))
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 39289942
Alexey,

Thanks for recommending my article.  Recommendations from fellow Experts are the highest form of praise :)

developingprogrammer: glad my code was useful to you!

Cheers,

Patrick
0
 

Author Comment

by:developingprogrammer
ID: 39289966
= ) thanks for all your help all this while Patrick! = )
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 custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

632 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