Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to dlookup up for multiple criteria

Posted on 2013-06-29
11
Medium Priority
?
440 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
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
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!

 

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

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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

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.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
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 …
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…
Suggested Courses

972 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