Solved

Access 2010 table-field in drop-down that limits choices based on other field

Posted on 2013-01-30
10
687 Views
Last Modified: 2013-01-31
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
0
Comment
Question by:JoeMommasMomma
  • 4
  • 4
  • 2
10 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 38836915
place this codes in the afterupdate event of combo WorkOut

private sub cboWorkOut_afterUpdate()

me.cboSteps.rowsource="select ID, StepName, WorkOutId from steps where WorkOutID=" & Me.cboWorkOut


end sub

if workoutID is Text Data Type use this

private sub cboWorkOut_afterUpdate()

me.cboSteps.rowsource="select ID, StepName, WorkOutId from steps where WorkOutID='" & Me.cboWorkOut & "'"


end sub
0
 
LVL 77

Expert Comment

by:peter57r
ID: 38838629
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.
0
 

Author Comment

by:JoeMommasMomma
ID: 38840335
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?
0
 
LVL 77

Expert Comment

by:peter57r
ID: 38840379
The code should all be on one line.
It's just the size of the  box here that makes it wrap.
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 38840383
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"
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:JoeMommasMomma
ID: 38841455
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.
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 38841642
where?

and better if you upload a copy of your db
0
 

Author Comment

by:JoeMommasMomma
ID: 38841777
it's too big to do that.  I thinking it's a relationship issue?  would macro be easier?
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 38841787
you don't need to upload the whole thing,
create a blank db and import only the relevant objects tables, form, query


or

just see this link(tutorial)

http://www.fontstuff.com/access/acctut10.htm
0
 

Author Comment

by:JoeMommasMomma
ID: 38841963
i've attached it. thanks again.
Database21.accdb
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
We were having a lot of "Heartbeat Alerts" in our SCOM environment, now "Heartbeat" in a SCOM environment for those of you who might not be familiar with SCOM is a packet of data sent from the agent to the management server on a regular basis, basic…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now