|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
Hi, I'm new to MS Access 2007 (and all versions of Access in general) and to this forum, though I have gotten a lot of very usefull information here, I am unable to figure out a problem I am having, so I thought I would beg for help before my deadline, which is two days from now. Anyway, here goes... I'm trying to figure out how to get one combo box to show items based on the users selection of another combo box. I've created a simple 2 control form. The controls are "Dept." and "Area". I need the areas to show up based on one of the three Depts that are available/selected in the first combo (cboDept) Simple right? So why can't I get it to work? I have created 4 tables. tblDept, tblDept1, tblDept2 and tblDept3. Each of the numbered tables has a few areas entered for testing. The tblDept has the names of the numbered tables (tblDept1, tblDept2, tblDept3). Combo 1 on the form called (cboDept) is bound to the tblDept so the drop down shows me the three choices that exist in tblDept(dept1, dept2, dept3). Based on which one they select, I want the areas for that dept to show up in the Area combo box. I have the following code on the after update event of the Dept combo box. Does anything jump out at you as being wrong with the code/expression? I'm lost now and I'm slowely pulling my freakin; hair out. Thanks VERY much guys and gals! I really need yoru help BAD. In AfterUpdate event of combo 1 (cboDept): Option Compare Database Private Sub CboDept_AfterUpdate() On Error Resume Next Select Case cboDept.Value Case "Dept 1" CboArea.RowSource = "Dept1Tbl" Case "Dept 2" CboArea.RowSource = "Dept2Tbl" Case "Dept 3" CboArea.RowSource = "Dept3Tbl" End Select End Sub Last edited by jmonica : April 29th, 2008 at 11:10 AM. Reason: Gave Access program version (2007) |
|
#2
|
|||
|
|||
|
Quote:
Have you tried Google http://www.google.ca/search?hl=en&q=msaccess+cascading+combo+boxes&btnG=Google+Search&meta= |
|
#3
|
||||
|
||||
|
My guess is that you need to get the combo box to requery.
Private Sub CboDept_AfterUpdate() ... CboArea.RowSource = "Dept3Tbl" End Select CboArea.Requery End Sub If that doesn't do it I usually force the select instead of just naming the table Private Sub CboDept_AfterUpdate() dim tblStr as string On Error Resume Next Select Case cboDept.Value Case "Dept 1" tblStr = "Dept1Tbl" Case "Dept 2" tblStr= "Dept2Tbl" Case "Dept 3" tblStr = "Dept3Tbl" End Select CboArea.Rowsource = "SELECT * FROM " & tblStr CboArea.Requery End Sub |
|
#4
|
|||
|
|||
|
Thanks!
Thanks so much for your reply. Tomorrow is my last day to work on this and hopefully when I get in I will trhy what you suggested and it will work. Thanks VERY much for your time and effort. Not only do I thiank you, but my wife and unborn child thank you because it may just keep me from losing my job! I'll post back to let you know it worked. Not just for thanks but for the benefit of the next person that might be having the same problem. Thanks again!
Jim End Quote:
|
|
#5
|
||||
|
||||
|
I had given you an answer off the top of my head. Becuase your deadline is so close I figured I'd check to make sure. Yes just adding the
cboArea.requery line to your existing code will change the values in the 2nd combo box. |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > Cascading Combo Box help, PLEASE? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|