473,789 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Conditional display of records based on user's multiple selections

Greetings
I have a simple MS-Access database with 2 tables in a many-to-many
relationship. One is a table of diseases and one is a table of
symptoms.
I need to create a form where all the symptoms show on the left side
with a checkbox. When one checkbox is clicked, the diseases associated
with the symptom show on the left side.
If another disease is selected, only the diseases associated with
both symptoms are displayed, and so on.
What would be the best way to create this form?
I'd be forever grateful to whoever can give me an idea of how to
solve this problem.

C

Nov 13 '05 #1
1 1616
cn****@gmail.co m wrote:
Greetings
I have a simple MS-Access database with 2 tables in a many-to-many
relationship. One is a table of diseases and one is a table of
symptoms.
I need to create a form where all the symptoms show on the left side
with a checkbox. When one checkbox is clicked, the diseases associated
with the symptom show on the left side.
If another disease is selected, only the diseases associated with
both symptoms are displayed, and so on.
What would be the best way to create this form?
I'd be forever grateful to whoever can give me an idea of how to
solve this problem.

C


Try This:

tblSymptoms
SID
Symptom
SCheckBox
tblDiseases
DID
Disease
DCheckBox
tblSymptomDisea ses
SDID
DID
SID

SubformDiseases .RowSource = SELECT Disease, DCheckBox FROM tblDiseases
ORDER BY DID;

SubformSymptoms .RowSource = SELECT Symptom, SCheckBox FROM tblSymptoms
ORDER BY SID;

cbxDiseases.Row Source = SELECT Disease FROM tblDiseases WHERE DID IN
(SELECT DID FROM tblSymptomDisea ses WHERE SID IN (SELECT SID FROM
tblSymptoms WHERE SCheckBox = -1) GROUP BY DID HAVING COUNT(DID) =
(SELECT COUNT(*) FROM tblSymptoms WHERE SCheckBox = -1));

cbxSymptoms.Row Source = SELECT Symptom FROM tblSymptoms WHERE SID IN
(SELECT SID FROM tblSymptomDisea ses WHERE DID IN (SELECT DID FROM
tblDiseases WHERE DCheckBox = -1) GROUP BY SID HAVING COUNT(SID) =
(SELECT COUNT(*) FROM tblDiseases WHERE DCheckBox = -1));

Note: the counts force the inclusion only of SID's that show up for
every DID checked and vice versa.

Code behind frmSubDiseases:
Private Sub DCheckbox_After Update()
Dim strBookmark As String

strBookmark = Me.Bookmark
Me.Requery
Me.Bookmark = strBookmark
Me.Parent!cbxSy mptoms.Requery
End Sub

Code behind frmSubSymptoms:
Private Sub SCheckbox_After Update()
Dim strBookmark As String

strBookmark = Me.Bookmark
Me.Requery
Me.Bookmark = strBookmark
Me.Parent!cbxDi seases.Requery
End Sub

Set the name of the first subform to SubformDiseases with Source Object
frmSubDiseases. Put cbxSymptoms below it.

Set the name of the second subform to SubformSymptoms with Source
Object frmSubSymptoms. Put cbxDiseases below it.

If everything is set up properly, clicking the checkboxes in
SubformDiseases will requery cbxSymptoms to show only the symptoms
common to all the diseases checked. Clicking the checkboxes in
SubformSymptoms will requery cbxDiseases to show only the diseases
common to all the symptoms checked.

Here is the data I used:

tblSymptoms
SID Symptom SCheckbox
1 FirstSymptom unchecked
2 SecondSymptom unchecked
3 ThirdSymptom checked

tblDiseases
DID Disease DCheckbox
1 FirstDisease unchecked
2 SecondDisease unchecked
3 ThirdDisease unchecked

tblSymptomDisea ses
SDID DID SID
1 1 1
2 1 2
3 1 3
4 2 1
5 3 1
6 3 3

This resulted in the dropdown for cbxDiseases showing FirstDisease and
ThirdDisease. After clicking DCheckbox for SecondDisease, the
cbxSymptoms dropdown became FirstSymptom.

The comboboxes should probably be changed into listboxes. Testing this
out was a lot of fun but it could use a little more testing.

James A. Fortune

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3527
by: Guy Hocking | last post by:
Hi there, I have a problem in my ASP/SQL Server application i am developing, i hope you guys can help. I have a ASP form with list boxes populated by SQL tables. When a user selects a value in a list box and submits the form the value is put into a session variable and the relevant page is displayed (in accordance to one of the list boxes). The page is then displayed with the relevant SQL data. So far i have got the
3
5935
by: Jouke Langhout | last post by:
Hello all! For quite some time now, I've got the following problem: Access won't close properly when a user closes the application. An ACCESS process stays active and that process can only be terminated by pressing ++ and then terminate the process. I searched the entire internet and found out that there could be two things wrong (both of them are mentioned in the bug list on the access
3
5370
by: Andante.in.Blue | last post by:
Hello everyone! I'm building a form in Access 97 and I want to to show a special icon if the record has been marked as deleted. Obviously, I don't want the icon to show if the record was not marked as deleted. I understand the conditional formatting is available in Access 2000 for this purpose, but it is not in 97. Is there a way to emulate this effect through code? Thanks for any input on this matter. Alan
2
1375
by: Colleyville Alan | last post by:
I have been working on a project that uses MS Access to get mutual fund performance and write it to a spreadsheet in a formatted manner. The user inputs the company name, the database looks at the company's 401k fund holdings and extracts the performance info and benchmark info for them. It writes out the information to a spreadsheet embedded on an Access form and simultaneously writes the same info to Excel. I also have logic built in...
2
2622
by: David | last post by:
Hi, I have an order form which has a field 'ProductID'. This form has a button on each record to open a new form linked by ProductID. This new form is a continuous form and obviously, only displays the records associated with that ProductID. Basically this is part of a Product Packing Pick System. From my products table, each product has a set default amount of items which
6
4898
by: Joe | last post by:
I have 2 multi-list boxes, 1 displays course categories based on a table called CATEGORIES. This table has 2 fields CATEGORY_ID, CATEGORY_NAME The other multi-list box displays courses based on a table called COURSES. This table has 2 fields CATEGORY_ID, COURSE_NAME. The CATEGORY_ID is a FK in COURSES and a PK in CATEGORIES. I want to populate the course list box based on any category(s)
3
2890
by: syounger | last post by:
Hi. I have a report in Access 2000 that is based on selection made from a series of interdependent list boxes. The boxes I have right now are Source, Table, Column, Date. The user chooses Source first, then the Table list box populates only tables from that source. Once a table is chosen, only the columns for that table appear in the Column list box. In the date box, the only dates that appear are those that are stored against the...
18
3352
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those columns, "scode" and "sname", as 1 column (if not possible then 2 columns will be fine) in the listbox. Can the listbox display 2 columns information from the dataset and how can I do that? Also, I set the property of the listbox to selectionmode...
4
8978
by: slinky | last post by:
Thanks in advance... I have a continuous style form with a field for each record called "STATUS". I simply want to have the form load and if the value of the textbox is "Inactive" I want the textbox background to display yellow, else I want it to be just white. Here's my code... but it is not working Private Sub Form_Load() If Me!STATUS = "Inactive" Then Me!STATUS.BackColor = RGB(255, 255, 0) Else
2
1268
by: twill005 | last post by:
Hi, I have created a DB containing server information for multiple servers. I used the multiselect function to select multiple softwares that are on an individual server, but I can't get my selections to display on the print preview of the form. Is there another way to display these multiple selections? Maybe in the table? More than one user will be viewing this DB, using it as a reference. Thanks in advance! PS. I do not know VBA,...
0
9663
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
10195
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
10136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9979
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9016
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6765
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();...
1
4090
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
2
3695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2906
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.