JoeMommasMomma
asked on
Access 2010 table-field in drop-down that limits choices based on other field
I am trying to limit the available values in a drop-down to show choices based on the value of another field. I have a table in Access 2010 named Tasks that has a column called "WorkOut".Presently that field's display control is a combo box that is a table/query. The Row source is another table called Workouts which consists of only 2 columns; WokoutsID and WorkoutName. In the tasks table there is another column called "Step" that is also a combo box that is a table/query. The row source is a table Called "Steps" which has 3 columns; ID, StepName and WorkOutId. In this WorkOutID column I have a look up to the WorkOuts table. I have a one to many relationship; the WorkOuts.WorkOutsID (unique) to the steps.WorkOutsId. I have 8 WorkOuts and each workout has anywhere from 1 to 13 steps. I want the drop down for the Step field in my Task table to only show the steps for what is specified in the WorkOut field. please let me know if you need any further info
Note that cap1's response assumes you are doing this in a form.
That is because what you are asking MUST be done in a form. It can't be done just entering data ina table.
That is because what you are asking MUST be done in a form. It can't be done just entering data ina table.
ASKER
Yes it is a form. I inserted the code but I get a compile error that reads "method or data member not found" and .cboWorkOut & "'" is highlighted in the debugger. Any ideas?
The code should all be on one line.
It's just the size of the box here that makes it wrap.
It's just the size of the box here that makes it wrap.
is the name of your combo box ".cboWorkOut " ?
if not then change
.cboWorkOut
with the name of your combo box
also do the same for "cboSteps"
if not then change
.cboWorkOut
with the name of your combo box
also do the same for "cboSteps"
ASKER
Hello, I have it on one line and I applied your naming conventions so the code would work. combo box for workout is cboWorkout and the one for steps is cboSteps. I forgot to mention that in the debugger, the little yellow arrow on the right is pointing to Private Sub cboWorkOut_afterUpdate() and these words are highlighted in yellow after I get the error pop-up. .cboWorkOut is not highlighted in yellow, but it is automatically selected by the debugger. thanks for your help. I have attached a screen shot.
where?
and better if you upload a copy of your db
and better if you upload a copy of your db
ASKER
it's too big to do that. I thinking it's a relationship issue? would macro be easier?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i've attached it. thanks again.
Database21.accdb
Database21.accdb
private sub cboWorkOut_afterUpdate()
me.cboSteps.rowsource="sel
end sub
if workoutID is Text Data Type use this
private sub cboWorkOut_afterUpdate()
me.cboSteps.rowsource="sel
end sub