473,509 Members | 2,828 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Compare tables based on Combobox selections

4 New Member
Hi,

I have a database to store my analyses (Access 2002, WinXp), the basic structure is:

TABLE 1 = Sample Info
TABLE 2 = Analysis type 1
TABLE 3 = Analysis type 2
TABLE 4 = Analysis type 3

....where each table stores results of a different type of analysis

TABLE 1 contains [SampleID], [SampleName] and other details
TABLE 2, 3 and 4 contain [SampleID], [Chemical], [%] as well as some other fields.

I use the [SampleID] field to link the tables back to TABLE 1, so that when I view the analysis I only see the relevant analyses.

I would like to be able to compare the samples for different types of analysis of the same sample and also be able to compare analyses of different samples.

My idea would be that you have 2 comboboxes for each comparison, e.g.
COMBOBOX 1 = [SampleID] and COMBOBOX 2 = Analysis type
this would let me select the first sample and the type of analysis to compare, then have another 2 comboboxes to set the second sample and analysis type to compare. The results would then appear on a form somehow.

I started by trying to build the table to compare using SQL, I tried using a query with an OUTER JOIN on the various tables, but it only allows me to see chemicals that are in the first table, if any chemicals appear in the second analysis then they are not shown. I'm not sure if this is the right way as I am not sure how to get it to select the types of analysis to compare from the comboboxes - even if I got it to work.

I would like to output something like:

Chemical , Type1 % , Type2 %
Chemical A , 10 , 20
Chemical B , 0 , 30
Chemical C , 50 , 0

I am self-taught in Access and know very little VB (only what I worked out from examples and help files).I am quite happy to muddle around trying to solve this but I think I've exhausted my knowledge. If someone could point me in the right direction I would appreciate it greatly.

Regards

Edd
Feb 9 '07 #1
5 2650
nico5038
3,080 Recognized Expert Specialist
When your [SampleID] is available in all "subtables" (2-3-4), then your outer JOIN should work.
Did you place the Table1 as the "master" for the link and the other 3 as "slaves" ?
(option 2 or 3) arrow lines should point from table1 to the others.

Nic;o)
Feb 10 '07 #2
NeoPa
32,557 Recognized Expert Moderator MVP
I'm a little confused by some of what you say. Can you clear up a couple of points for me :
  1. Is there data in the master table (TABLE 1) for every SampleID that exists?
  2. Do you really mean OUTER JOIN?
    An OUTER JOIN in a query is when there is NO link between the tables.
    I suspect, from what you're saying, that you are using a LEFT or RIGHT JOIN.
I would expect that your source should be along the lines of :
Expand|Select|Wrap|Line Numbers
  1. ...
  2. FROM ((([TABLE 1] LEFT JOIN [TABLE 2]
  3.   ON [TABLE 1].SampleID=[TABLE 2].SampleID)
  4.   LEFT JOIN [TABLE 3]
  5.   ON [TABLE 1].SampleID=[TABLE 3].SampleID)
  6.   LEFT JOIN [TABLE 4]
  7.   ON [TABLE 1].SampleID=[TABLE 4].SampleID)
  8. ...
Feb 11 '07 #3
Edd E
4 New Member
I'm a little confused by some of what you say. Can you clear up a couple of points for me :
  1. Is there data in the master table (TABLE 1) for every SampleID that exists?
  2. Do you really mean OUTER JOIN?
    An OUTER JOIN in a query is when there is NO link between the tables.
    I suspect, from what you're saying, that you are using a LEFT or RIGHT JOIN.
I would expect that your source should be along the lines of :
Expand|Select|Wrap|Line Numbers
  1. ...
  2. FROM ((([TABLE 1] LEFT JOIN [TABLE 2]
  3.   ON [TABLE 1].SampleID=[TABLE 2].SampleID)
  4.   LEFT JOIN [TABLE 3]
  5.   ON [TABLE 1].SampleID=[TABLE 3].SampleID)
  6.   LEFT JOIN [TABLE 4]
  7.   ON [TABLE 1].SampleID=[TABLE 4].SampleID)
  8. ...
Hi,

Firstly thank you both for your help.

I have set up a query as Nico suggested with the arrows going the correct way (my initial attempt had them the right way as well). This gives me the same FROM statement as NeoPa has listed.

I'm now trying to work out which fields I should be including in the SELECT part, each table (TABLE 2, 3 and 4) has a [Chemical] and [%] field. If I select both these from each table then I get a table with multiple chemical and % columns, SELECT statement is:
Expand|Select|Wrap|Line Numbers
  1. ...
  2. SELECT [TABLE1].[SampleID], 
  3. [TABLE 2].Chemical, [TABLE 2].[%], 
  4. [TABLE 3].Chemical, [TABLE 3].[%], 
  5. [TABLE 4].Chemical, [TABLE 4].[%]
  6.  
Feb 13 '07 #4
Edd E
4 New Member
oops...hit submit by accident and timed out editing post....

I am assuming I need this layout to enable the comparison between samples? Looking at the worksheet it appears to be comparing analyses for the same sample (although with multiple repeated lines of same chemical) i.e it appears to take Chemical A in TABLE 2 and list it against each chemical in TABLE 3, then take Chemical B and list against every chemical in TABLE 3 etc.

If so how would I go about getting to select which sample/analysis to compare? I will have a try but I'm not sure what commands I would need to use, would it be a simple LIKE function as I have been using for searches? but adjusted to suit multiple inputs?
Expand|Select|Wrap|Line Numbers
  1. Me.Filter = "[Chemical] LIKE '*" & TXTSEARCH.Value & "*' OR [Synonyms] LIKE '*" & TXTSEARCH.Value & "*'"
  2.  
Once again thank you for your help and patience! I shall try sorting out a form to enable me to select which analyses to compare.

Regards

Edd
Feb 13 '07 #5
NeoPa
32,557 Recognized Expert Moderator MVP
First, use the AS keyword in your query to rename the returned fields :
Expand|Select|Wrap|Line Numbers
  1. SELECT [TABLE1].[SampleID], 
  2.        [TABLE 2].Chemical AS Chem2, [TABLE 2].[%] AS PC2, 
  3.        [TABLE 3].Chemical AS Chem3, [TABLE 3].[%] AS PC3, 
  4.        [TABLE 4].Chemical AS Chem4, [TABLE 4].[%] AS PC4
  5. ...
Feb 13 '07 #6

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

Similar topics

3
6674
by: Niels | last post by:
Hello, I'm trying to get te index of a specific text in a ComboBox. The ComboBox is filled by searching for filenames in a directory. The text of the last item selected in the ComboBox is saved in...
31
3650
by: Neil | last post by:
I have an Access 2000 MDB with ODBC linked tables to a SQL Server 7 back end. I currently have a selections table in the front end file which the users use to make selections of records. The table...
5
3048
by: Steve | last post by:
I have an unbound combobox in the form header of a continuous form. The selection in the combobox sets the where clause in a querydef which determines QryPFrmInventoryManagement. The following code...
5
10855
by: Megan | last post by:
Hi everybody- I'm helping a friend with a music database. She has an old one and is creating a new one. She wants to compare records and fields in the old database with records and fields in the...
11
4501
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my...
2
1040
by: Sam | last post by:
Hi, I have a datagrid which contains a combobox column bound to a datatable(I'm using VS2003 but it's a custom control). For each of the combobox I would like to achieve the same behaviour as for...
4
23009
by: WhiteWizard | last post by:
Alright everyone, I've managed to stump this group 2 or 3 times now. Don't let me down on this one ;) I have a combo box that lists a number of tests to be run. The user would like the option...
6
3359
by: BerkshireGuy | last post by:
On an unbound form, I have a combobox called 'cboproducttype' and a text box called 'txtamountappliedfor'. I have an Add button that I would like the user to be able to hit once a product and...
0
3149
by: Germaris | last post by:
Hi there! Is it possible to make multiple selections in a ComboBox ? i.e. make n consecutive selections and store them in an array or make n selections in the open list of the CB by using (for...
0
7237
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7347
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7416
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5656
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5062
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
443
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.