473,382 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Select/Filter a one to many link

In Access 2007, I have an issue that I've tried attacking from different angles, but have not gotten the correct results.

I have two tables, tblBase and tblAttributes with a common Key of Stock_ID. In tblBase, I have a Description of the item, but the more detailed attributes are handled in tblAttributes with field names Attribute_Type and Attribute_Value.

Sample Data is:
Stock_ID -- Attr_Type -- Attr_Value
00001 -- Brand -- Finest
00001 -- Year -- 2010
00002 -- Brand -- Finest
00002 -- Year -- 2009
00003 -- Player -- Thomas
00003 -- Player -- Stevens
00003 -- Brand -- Bowman ....

I have identified 18 different Attribute_Types that could show up for each Stock_ID but most of the stock items will touch on only 5 or 6 of these. However there are a few Types that could contain more than 1 Value such as 00003-Player-... above.

What I wish to do is filter down to a listing of Stock Items that contain user-selected options based on the attributes chosen via combo-boxes or other form inputs. For instance, if I choose Brand - Finest only, it would give me 00001, 00002...but if I choose Brand - Finest and Year - 2009, it would only give me 00002.

However, I am unsure of how to do this. I have thought about a crosstab query but in Access, the Value field will not work when I have a situation with one item have multiple players involved. I thought about a standard filter, but I get a situation where if I select an "AND", it will not work as each record is only 1 attribute. The "OR" gives me every line that matches any criteria chosed.

I tried to minimize empty cells in records with the original plotting of this database while still retaining standard data normalization, but I'm not sure of how to proceed? Thoughts that I might not be considering and thank you in advance.
Sep 20 '12 #1
5 1826
TheSmileyCoder
2,322 Expert Mod 2GB
Exactly how are you going to use this?

User(s) select from a form several limiting factors, and you want to show the first match/all matches?

Maybe some of our SQL gurus can cook up something smarter, but my approach would probably be to use VBA to create and save a querydef after the update of each criteria, and have the 2nd query query from the first query.

So user selects criteria 1, and code creates Qry_MatchesCrit1, and user then selects criteria 2, and code created qry_MatchesCrit2 which queries FROM qry_MatchesCrit1. You should be able to do all of this dynamically.
Sep 20 '12 #2
That was a 3rd thought I had; but I wasn't sure if I could in theory have 18+ nested querydefs since that's feasible as a drill-down.

My end goal is I want to use every record that matches the final listing and allow the user to add it to a wishlist/order form so limiting the results to just what is targeted is key.
Sep 20 '12 #3
Rabbit
12,516 Expert Mod 8TB
I'm thinking you could do a dynamic query that would do something like this:
Expand|Select|Wrap|Line Numbers
  1. SELECT id
  2. FROM someTable
  3. WHERE 
  4.    (field1 = something AND field2 = something) OR
  5.    (field1 = otherthing AND field2 = otherthing) OR
  6.    (field1 = thirdthing AND field2 = thirdthing)
  7. GROUP BY id
  8. HAVING COUNT(*) >= 3
This will return all ids that have those attributes matching. Any id with less than those 3 attributes would not get returned.

A potential issue is that ORs can be really slow and you may have to use an equivalent UNION query instead.
Sep 20 '12 #4
Rabbit, sorry for the delay in responding. I went ahead with your idea as a solution for now becuase I hadn't thought about the HAVING option. That's exactly what I was aiming for and until I run into speed concerns, it's what I will go with. Thank you.
Sep 24 '12 #5
Rabbit
12,516 Expert Mod 8TB
Not a problem HSX. Good luck with the rest of your project.
Sep 24 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Xiaofeng Zhang | last post by:
when I compile my project setting, there are many LINK errors. But when I compile my project under debug setting, everything is OK. How can I deal with it? The errors is followed. Linking......
1
by: Ron Vecchi | last post by:
I am using the Select method on a DataTable to return a DataRow filter = (width LIKE '%width="%') I am getting an exception saying my filter is invalid I narrowed it down to the part that reads ...
7
by: wk6pack | last post by:
Hi, How do I check datatable.select(filter) in the following: for each dtrow in datatable.select(filter) .... next I've also tried:
12
by: Claude | last post by:
Hi, I've designed my own form checking code for name, address, email, comment box etc. What my client keeps getting in his consumer feedback forms is "spam" from companies who repeatedly...
11
by: MurdockSE | last post by:
Greetings. My Situation: // I have an .xml file that I am reading into a dataset in the following code - DataSet ds = new DataSet("MyDataset"); ds.ReadXml(@"c:\data\"+cmyxmlfilename);
4
by: =?Utf-8?B?Q2Fpcm4=?= | last post by:
I am new to Xpath but wish to parse an XML document for nodes which contain a child node with a particuale value. Please does anybody have any clues as to why I never get any returns in the root...
1
by: stierle | last post by:
Background: I'm using Access 2000 and have a form with several listboxes on it (listB, listP, listT) I'm need to find a way to link items from different boxes. I have a matchID in the table and...
2
gchq
by: gchq | last post by:
Hi there I have a DataTable that has the following elements:- (Sorry about the formatting ) id Status Lower Upper Percent Amount Less 0 Single 0 8389 20.4 0 0 1 Single 8390 15389 0 1712 0...
2
by: franc sutherland | last post by:
Hello, I am using Access 2003. I have a query which shows a list of club meetings sorted by date. This query is displayed in continuous forms, in a subform. I would like to select a month on...
0
by: --CELKO-- | last post by:
"A problem well stated is a problem half solved." -- Charles F. Kettering Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.