Hello,
I have a question for something, which only seems obvious on the surface.
I have a lookup table that contains information (let's say minimum time for something) depending on the characteristics of some criteria (let's say material, shape, color, weight). The lookup table doesn't contain a record for all combinations of these criteria, but rather uses blank entries as wild cards. The following is an example:
[FONT="]material/shape/color/weight/time[/FONT]
[FONT="]wood/square/red/heavy/20[/FONT]
[FONT="]plastic/circle/blue/heavy/30[/FONT]
[FONT="]wood//red//50[/FONT]
[FONT="]wood///light/40[/FONT]
[FONT="]metal////100[/FONT]
[FONT="]metal/circle/yellow/light/20[/FONT]
[FONT="]////200[/FONT]
I now want to query this table and it should return the record (time), which satisfies the most criteria. So e.g. if I query for:
material = wood, shape = square, color = red, weight = heavy
it should return 20
if I query for:
material = wood, shape = triangle, color = red, weight = heavy
it should return 50
if I query for:
material = wood, shape, triangle, color = red, weight = leight
two entries satisfy this with two criteria, it could return 40 or 50, in which case I want to return the minimum.
I'm wondering, how to best do this. The "criteria" entries are in another long table. In reality, there is not only 4 criteria, but about 20, some of which are the details of others.
I could think of 2 solutions:
- Write a function in visual basic, which does several a dlookups (grrr....) or creates recordsets, which it searches.
- Create a complicated query, which I'm not exactly sure how to go about...
On the first, I'm worried about performance, as the criteria table could have many entries, and it would have to do many lookups/searches
On the second, I'm - as I said - puzzled on how to do that, and how to go about the wildcards.
Any advise would be highly appreciated...
Many thanks
Jan
I have a question for something, which only seems obvious on the surface.
I have a lookup table that contains information (let's say minimum time for something) depending on the characteristics of some criteria (let's say material, shape, color, weight). The lookup table doesn't contain a record for all combinations of these criteria, but rather uses blank entries as wild cards. The following is an example:
[FONT="]material/shape/color/weight/time[/FONT]
[FONT="]wood/square/red/heavy/20[/FONT]
[FONT="]plastic/circle/blue/heavy/30[/FONT]
[FONT="]wood//red//50[/FONT]
[FONT="]wood///light/40[/FONT]
[FONT="]metal////100[/FONT]
[FONT="]metal/circle/yellow/light/20[/FONT]
[FONT="]////200[/FONT]
I now want to query this table and it should return the record (time), which satisfies the most criteria. So e.g. if I query for:
material = wood, shape = square, color = red, weight = heavy
it should return 20
if I query for:
material = wood, shape = triangle, color = red, weight = heavy
it should return 50
if I query for:
material = wood, shape, triangle, color = red, weight = leight
two entries satisfy this with two criteria, it could return 40 or 50, in which case I want to return the minimum.
I'm wondering, how to best do this. The "criteria" entries are in another long table. In reality, there is not only 4 criteria, but about 20, some of which are the details of others.
I could think of 2 solutions:
- Write a function in visual basic, which does several a dlookups (grrr....) or creates recordsets, which it searches.
- Create a complicated query, which I'm not exactly sure how to go about...
On the first, I'm worried about performance, as the criteria table could have many entries, and it would have to do many lookups/searches
On the second, I'm - as I said - puzzled on how to do that, and how to go about the wildcards.
Any advise would be highly appreciated...
Many thanks
Jan
Last edited: