473,608 Members | 1,821 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 2657
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,566 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,566 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
6683
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 a textfile in the OnExit Event of the Mainform. While loading the Mainform I want the text that was saved in the file to be compared with the items in the ComboBox ad get the index of the found item, so that I can set it as selected. I...
31
3666
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 has two fields -- primary key (which matches primary key of main, SQL Server table), and a boolean field. The table is linked to the main table in a heterogeneous inner join. I'm looking to move the table to the back end, while still giving each...
5
3060
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 is in the afterupdate event of the combobox: Me.RecordSource = "QryPFrmInventoryManagement" Me!ItemCount = Me.RecordsetClone.RecordCount & " Items" MsgBox Me.RecordsetClone.RecordCount & " Items"
5
10862
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 new database. For instance, her old database has a table with Band Info in it. Her new database also has a table with Band Info in it but slightly different. I was wondering if there was an easy way to compare the fields from similar tables in...
11
4514
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 database,just help in getting me pointed in the right direction. I have a database with 8 tables, which from what I have read, cannot be linked on a single form, and be updatable. I have created a query which includes all 8 tables, and then...
2
1045
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 the font selector in word, that is the most recent chosen fonts are added to the top of the list. Exemple: Say your comboboxes contain the following values: test0
4
23024
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 of being able to select several of the items in the ComboBox at one time, then have them added to the listbox that details the tests. Currently it works fine when they select one test at a time, but often they have multiple tests they need to run....
6
3375
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 amount applied for has been entered. This should populate an unbound listbox to display their selections. A user can select one or more sets of product types and the amount applied for. They should also have the functionality to remove a 'set' if...
0
3160
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 example) the click-Shift Key keystroke Purpose is to allow the user to select multiple different issues of a magazine with a maximum ease of use... (Code I use is attached below) Many thanks for your help!
0
8071
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8503
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8488
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6017
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5489
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3977
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4039
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2482
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1613
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.