Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old April 29th, 2008, 11:04 AM
jmonica jmonica is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 2 jmonica User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 58 sec
Reputation Power: 0
Question Cascading Combo Box help, PLEASE?

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)

Reply With Quote
  #2  
Old April 30th, 2008, 07:43 AM
orange orange is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Posts: 35 orange User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 23 m 3 sec
Reputation Power: 1
Quote:
Originally Posted by jmonica
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


Have you tried Google

http://www.google.ca/search?hl=en&q=msaccess+cascading+combo+boxes&btnG=Google+Search&meta=

Reply With Quote
  #3  
Old April 30th, 2008, 04:40 PM
dykebert's Avatar
dykebert dykebert is offline
Contributing User
Click here for more information. Click here for more information
 
Join Date: Apr 2008
Posts: 200 dykebert User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 3 h 32 m 29 sec
Reputation Power: 1
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

Reply With Quote
  #4  
Old April 30th, 2008, 05:31 PM
jmonica jmonica is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 2 jmonica User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 58 sec
Reputation Power: 0
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:
Originally Posted by dykebert
My guess is that you need to get the combo box to requery.

Private Sub CboDept_AfterUpdate()
...
CboArea.RowSource = "Dept3Tbl"
End Select
[b]CboArea.Requery[b]
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

Sub

Reply With Quote
  #5  
Old April 30th, 2008, 08:35 PM
dykebert's Avatar
dykebert dykebert is offline
Contributing User
Click here for more information. Click here for more information
 
Join Date: Apr 2008
Posts: 200 dykebert User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 3 h 32 m 29 sec
Reputation Power: 1
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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > Cascading Combo Box help, PLEASE?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway