wiklendt
i recommend chocolate
- Local time
- Today, 17:10
- Joined
- Mar 10, 2008
- Messages
- 1,746
hi,
i thought i was nearly finished this ddb, but then i was asked by my client to chenge a few things... so i'm back in the depths of the form design...
let's see if i can untangle this mess. i'll mention only what's applicable to my problem(s):
CASCADING COMBO/LIST
SETUP
i have a form with a combobox (cmbMuscleRegion), a listbox (lstMuscleByGroup) and a few textboxes (txtFunction, txtSymptoms, txtTreatment).
i also have a few queries, which i have been using as sources for the listbox based on values in the combobox (using SELECT CASE to individually hard code each option to source a different query for the listbox in each case). the combo lists groups, which fires each case, in turn displaying a different query (each query specifically filtering the data using the same groups as in the combo but not using the combo directly to filter, i did it this way b/c when i started i was just learning and i didn't know a better way to do it).
e.g., what was there before:
WHAT CHANGED
however, there has been an addition of 29 extra cases in the combo, and i don't want to have to create a query for each. i wanted to use ONE query that displays ALL the data, and then to use an SQL statement in the after-update event to filter the records that match the combo value.
LITTLE MORE ABOUT MY ASSETS
now a little about my query... i have three tables. tblMuscles tblGroups and tblMusclesInGroups. the third table associates each muscle with one or more groups. my query (qryMuscleDISTINCTgroups) returns the Muscle and Group names from the tblMusclesInGroups, as well a couple of useful fields from the tblMuscles.
THE PROBLEMATIC CODE
now, in the form_load event, i have stated to use the unfiltered query (qryMuscleDISTINCTgroups).
This works fine, displaying the columns i want, except that the query returns each combination of muscle and group... so there may be double-ups of a muscle name. however, when i try to make any attempt to filter the data, my queries always without fail come back null... this is my latest attempt. specifically, this code below does not fire an error dialog msg by access, but also does not select ANY data! however, other version of this have triggered a parameter dialog box asking for either MuscleName or some such.
i'm at my wits end with this one, i've tried so many different things, followed so many different tutorials on cascading combos, and have read extensively the posts on this and other forums.... nothing i code seems to work (just when i thought i could upgrade my status from beginner to amateur!)
UPDATING TEXT BOXES
there are the three text boxes i mentioned earlier: txtFunction, txtSymptoms and txtTreatments.
i have these fields in my unfiltered query (qryMuscleDISTINCTgroup) so that (when it works) when the user selects a group from the combo, the listbox populates with the appropriate filtered muscles. Now, to choose a muscle, the user clicks once on the listed name in the listbox, and the correct associated function, symptom and treatment for that selected record ought to pop into the text boxes on the form.
so far i have been able to get "#Name?" appear in the appropriate text box, but not the actual text! i tried changing the bound columns, checked column number (zero based) etc etc...
i would have thought this would be simple, and have been trying various code this is what i thought would be most logical:
instead of ItemsSelected i've also tried almost anything else that looked data related in the dropdown VB gives you after you put in the period, however, i keep getting "compile error: method or data member not found" or says invalid use of property or some such. often highlighting either the bit after "lstMuscleByGroup." or highlighting the ".Column" part.
e.g, with .value, i get "error #424: object required"
if anyone can help, i'd be MUCH appreciated. i've been working on the code all weekend with no luck (tho i got excited even to see "#Name?" in the textboxes!!!)
cheers,
agnieszka.
i thought i was nearly finished this ddb, but then i was asked by my client to chenge a few things... so i'm back in the depths of the form design...
let's see if i can untangle this mess. i'll mention only what's applicable to my problem(s):
CASCADING COMBO/LIST
SETUP
i have a form with a combobox (cmbMuscleRegion), a listbox (lstMuscleByGroup) and a few textboxes (txtFunction, txtSymptoms, txtTreatment).
i also have a few queries, which i have been using as sources for the listbox based on values in the combobox (using SELECT CASE to individually hard code each option to source a different query for the listbox in each case). the combo lists groups, which fires each case, in turn displaying a different query (each query specifically filtering the data using the same groups as in the combo but not using the combo directly to filter, i did it this way b/c when i started i was just learning and i didn't know a better way to do it).
e.g., what was there before:
Code:
Case "Head"
lstMuscleByGroup.RowSource = "qryMusclesHead"
WHAT CHANGED
however, there has been an addition of 29 extra cases in the combo, and i don't want to have to create a query for each. i wanted to use ONE query that displays ALL the data, and then to use an SQL statement in the after-update event to filter the records that match the combo value.
LITTLE MORE ABOUT MY ASSETS
now a little about my query... i have three tables. tblMuscles tblGroups and tblMusclesInGroups. the third table associates each muscle with one or more groups. my query (qryMuscleDISTINCTgroups) returns the Muscle and Group names from the tblMusclesInGroups, as well a couple of useful fields from the tblMuscles.
THE PROBLEMATIC CODE
now, in the form_load event, i have stated to use the unfiltered query (qryMuscleDISTINCTgroups).
Code:
lstMuscleByGroup.RowSource = "qryMuscleDISTINCTgroup"
Code:
lstMuscleByGroup.RowSource = "SELECT " & _
"qryMuscleDISTINCTgroup.MuscleName, " & _
"qryMuscleDISTINCTgroup.MuscleDepth, " & _
"qryMuscleDISTINCTgroup.GroupID, " & _
"qryMuscleDISTINCTgroup.MuscleFunction, " & _
"qryMuscleDISTINCTgroup.MuscleInnervation, " & _
"qryMuscleDISTINCTgroup.MuscleNotes " & _
"qryMuscleDISTINCTgroup.MuscleID " & _
"FROM qryMuscleDISTINCTgroup" & _
"GROUP BY qryMuscleDISTINCTgroup.MuscleName;"
UPDATING TEXT BOXES
there are the three text boxes i mentioned earlier: txtFunction, txtSymptoms and txtTreatments.
i have these fields in my unfiltered query (qryMuscleDISTINCTgroup) so that (when it works) when the user selects a group from the combo, the listbox populates with the appropriate filtered muscles. Now, to choose a muscle, the user clicks once on the listed name in the listbox, and the correct associated function, symptom and treatment for that selected record ought to pop into the text boxes on the form.
so far i have been able to get "#Name?" appear in the appropriate text box, but not the actual text! i tried changing the bound columns, checked column number (zero based) etc etc...
i would have thought this would be simple, and have been trying various code this is what i thought would be most logical:
Code:
Private Sub lstMuscleByGroup_Click()
On Error GoTo Err_lstMuscleByGroup_Click
Me.txtFunction.ControlSource = Me.lstMuscleByGroup.ItemsSelected.Column(3)
Me.txtSymptoms.ControlSource = Me.lstMuscleByGroup.ItemsSelected.Column(4)
Me.txtTreatment.ControlSource = Me.lstMuscleByGroup.ItemsSelected.Column(5)
Exit_lstMuscleByGroup_Click:
Exit Sub
Err_lstMuscleByGroup_Click:
Msg = "Error # " & Str(Err.Number) & Chr(13) & Err.Description
MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
Resume Exit_lstMuscleByGroup_Click
End Sub
e.g, with .value, i get "error #424: object required"
if anyone can help, i'd be MUCH appreciated. i've been working on the code all weekend with no luck (tho i got excited even to see "#Name?" in the textboxes!!!)
cheers,
agnieszka.
Last edited: