473,408 Members | 2,030 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,408 software developers and data experts.

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 1601
cn****@gmail.com 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
tblSymptomDiseases
SDID
DID
SID

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

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

cbxDiseases.RowSource = SELECT Disease FROM tblDiseases WHERE DID IN
(SELECT DID FROM tblSymptomDiseases WHERE SID IN (SELECT SID FROM
tblSymptoms WHERE SCheckBox = -1) GROUP BY DID HAVING COUNT(DID) =
(SELECT COUNT(*) FROM tblSymptoms WHERE SCheckBox = -1));

cbxSymptoms.RowSource = SELECT Symptom FROM tblSymptoms WHERE SID IN
(SELECT SID FROM tblSymptomDiseases 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_AfterUpdate()
Dim strBookmark As String

strBookmark = Me.Bookmark
Me.Requery
Me.Bookmark = strBookmark
Me.Parent!cbxSymptoms.Requery
End Sub

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

strBookmark = Me.Bookmark
Me.Requery
Me.Bookmark = strBookmark
Me.Parent!cbxDiseases.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

tblSymptomDiseases
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
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...
3
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...
3
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...
2
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...
2
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...
6
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...
3
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...
18
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...
4
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...
2
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...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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
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...

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.