If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Subform combo boxes
Hello,
I need to design a subform (in datasheet view), on which will be two drop-down boxes and maybe a text box. The first combo is called 'categories' of which there are four types. The second combo is called 'symptoms'. A category can consist of many symptoms. This relation is reflected at table-level. Is it possible to have the first combo designed so that when the user selects the category, the second combo shows only those symptoms relevant to that category? Sorry if this question has been asked before, but this is not something I have experience with. TIA for any help. |
#2
|
|||
|
|||
Subform combo boxes
This is generally referred to as a cascading combo box. Here is a way to
implement this: http://www.fontstuff.com/access/acctut10.htm The second example is the one you need, I expect. The first one should not be considered unless it uses named queries rather than tables. Considering that there are just four categories this would not be a bad choice, but I really don't think it is much easier. The second one is more versatile if you add new categories. Presumably you have tables something like this: tblCategory CatID (primary key, or PK) Description etc. tblSymptom SymptomID (PK) CatID Symptom In the category combo box (cboCat), the stored value is CatID. In the After Update event, something like: Dim strSQL as String strSQL = "SELECT [SymptomID], [Symptom] " & _ "FROM tblSymptom " & _ "WHERE [CatID] = " & Me.cboCat & _ " ORDER BY [Symptom]" Me.cboSymptom.RowSource = strSQL The above assumes the ID fields are Number fields. In both combo boxes, the Row Count is 2, the Bound Column is 1 (that is, you are storing the ID, not the text description of Category and Symptom), and the Column Widths are something like 0";1.5". The cboCategory Row Source would be similar, except without the WHERE, since you want to see all Category records. Mo wrote: Hello, I need to design a subform (in datasheet view), on which will be two drop-down boxes and maybe a text box. The first combo is called 'categories' of which there are four types. The second combo is called 'symptoms'. A category can consist of many symptoms. This relation is reflected at table-level. Is it possible to have the first combo designed so that when the user selects the category, the second combo shows only those symptoms relevant to that category? Sorry if this question has been asked before, but this is not something I have experience with. TIA for any help. -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/201002/1 |
#3
|
|||
|
|||
Subform combo boxes
On 04/02/2010 12:35, BruceM via AccessMonster.com wrote:
This is generally referred to as a cascading combo box. Here is a way to implement this: http://www.fontstuff.com/access/acctut10.htm The second example is the one you need, I expect. The first one should not be considered unless it uses named queries rather than tables. Considering that there are just four categories this would not be a bad choice, but I really don't think it is much easier. The second one is more versatile if you add new categories. Presumably you have tables something like this: tblCategory CatID (primary key, or PK) Description etc. tblSymptom SymptomID (PK) CatID Symptom In the category combo box (cboCat), the stored value is CatID. In the After Update event, something like: Dim strSQL as String strSQL = "SELECT [SymptomID], [Symptom] "& _ "FROM tblSymptom "& _ "WHERE [CatID] = "& Me.cboCat& _ " ORDER BY [Symptom]" Me.cboSymptom.RowSource = strSQL The above assumes the ID fields are Number fields. In both combo boxes, the Row Count is 2, the Bound Column is 1 (that is, you are storing the ID, not the text description of Category and Symptom), and the Column Widths are something like 0";1.5". The cboCategory Row Source would be similar, except without the WHERE, since you want to see all Category records. Thanks very for the response Bruce. I'll give it a try out and see how it goes. |
#4
|
|||
|
|||
Subform combo boxes
Assuming that you have two tables (one to many) Categories and Symptoms then
on the lookout of sympltoms put something like the following as a criterion under category [Forms]![YourMainFormName]![YourSubformName].[Form]![YourCategoryField] Also, have this textbox (lookup) to requery it self (i.e. after update of the category field) Hope this helps, GeorgeCY Ο χρήστης "Mo" *γγραψε: Hello, I need to design a subform (in datasheet view), on which will be two drop-down boxes and maybe a text box. The first combo is called 'categories' of which there are four types. The second combo is called 'symptoms'. A category can consist of many symptoms. This relation is reflected at table-level. Is it possible to have the first combo designed so that when the user selects the category, the second combo shows only those symptoms relevant to that category? Sorry if this question has been asked before, but this is not something I have experience with. TIA for any help. . |
Thread Tools | |
Display Modes | |
|
|