- Joined
- May 11, 2012
- Messages
- 1
- Reaction score
- 0
Hello All!
I am using a simple application on an Access 2007 form, in which I use 2 Comboboxes, one for Districts and the other for Sub-Districts (called Blocks). No matter how much I've tried to get these ComboBoxes to work, they don't work.
The District and Block tables are related in Access 2007 by a One to Many relationship. I have made use of the example which is given in:
blogs.office.com/b/microsoft-access/archive/2009/04/03/template-demonstrates-how-to-synchronize-combo-boxes.aspx]Access Blog - Template demonstrates how to synchronize combo boxes
"How to synchronize combo boxes"
; but this also hasn't been able to fix the issue.
I use the same code given in the example like so in the After_Update event:
Private Sub cboCategories_AfterUpdate()
Me.cboProducts.RowSource = "SELECT ProductName FROM" & _
" Products WHERE CategoryID = " & Me.cboCategories & _
" ORDER BY ProductName"
Me.cboProducts = Me.cboProducts.ItemData(0)
End Sub()
But just changed the names of the ComboBoxes to Districts and Blocks as appropriate for my application.
The above code does populate the District ComboBox with the list of Districts which I can select but choosing a District from this ComboBox does not filter the Block ComboBox with the list of Blocks pertaining to the District chosen.
Can anyone please help me out with this ???
All help is greatly appreciated.
Thanks.
Maneesh
UPDATE:
Ok, guys, I have lately discovered some other articles that show how to go about Cascading ComboBoxes in Access. Among the best are :
fmsinc.com/MicrosoftAccess/Forms/combo-boxes/cascading.html]Microsoft Access Form Cascading Combo Boxes and
office.microsoft.com/en-ca/access-help/basing-one-combo-box-on-another-HA001173058.aspx?pid=CH063650361033]Basing one combo box on another - Access - Office.com
I have used both in my Access Form and yet it still is not working.
The code I am using is given below:
Private Sub cboDistrict_AfterUpdate()
Me.cboBlock.RowSource = "SELECT BlockID, Blocks, DistrictID " & _
"FROM Block " & _
"WHERE DistrictID = " & (Me.cboDistrict) & _
"ORDER BY Blocks"
Me.cboBlock = Me.cboBlock.ItemData(0)
End Sub
Private Sub Form_Load()
Me!cboDistrict = Me!cboDistrict.ItemData(0)
Call cboDistrict_AfterUpdate
End Sub
Can someone PLEASE HELP ME ??????
Why is this not working as it is intended to work ??????????
Please help me out, as I have been working on this for the whole week and still can't get it to work !!
Thanks a lot !
Maneesh
maneeshmassey at gmail dot com
I am using a simple application on an Access 2007 form, in which I use 2 Comboboxes, one for Districts and the other for Sub-Districts (called Blocks). No matter how much I've tried to get these ComboBoxes to work, they don't work.
The District and Block tables are related in Access 2007 by a One to Many relationship. I have made use of the example which is given in:
blogs.office.com/b/microsoft-access/archive/2009/04/03/template-demonstrates-how-to-synchronize-combo-boxes.aspx]Access Blog - Template demonstrates how to synchronize combo boxes
"How to synchronize combo boxes"
; but this also hasn't been able to fix the issue.
I use the same code given in the example like so in the After_Update event:
Private Sub cboCategories_AfterUpdate()
Me.cboProducts.RowSource = "SELECT ProductName FROM" & _
" Products WHERE CategoryID = " & Me.cboCategories & _
" ORDER BY ProductName"
Me.cboProducts = Me.cboProducts.ItemData(0)
End Sub()
But just changed the names of the ComboBoxes to Districts and Blocks as appropriate for my application.
The above code does populate the District ComboBox with the list of Districts which I can select but choosing a District from this ComboBox does not filter the Block ComboBox with the list of Blocks pertaining to the District chosen.
Can anyone please help me out with this ???
All help is greatly appreciated.
Thanks.
Maneesh
UPDATE:
Ok, guys, I have lately discovered some other articles that show how to go about Cascading ComboBoxes in Access. Among the best are :
fmsinc.com/MicrosoftAccess/Forms/combo-boxes/cascading.html]Microsoft Access Form Cascading Combo Boxes and
office.microsoft.com/en-ca/access-help/basing-one-combo-box-on-another-HA001173058.aspx?pid=CH063650361033]Basing one combo box on another - Access - Office.com
I have used both in my Access Form and yet it still is not working.
The code I am using is given below:
Private Sub cboDistrict_AfterUpdate()
Me.cboBlock.RowSource = "SELECT BlockID, Blocks, DistrictID " & _
"FROM Block " & _
"WHERE DistrictID = " & (Me.cboDistrict) & _
"ORDER BY Blocks"
Me.cboBlock = Me.cboBlock.ItemData(0)
End Sub
Private Sub Form_Load()
Me!cboDistrict = Me!cboDistrict.ItemData(0)
Call cboDistrict_AfterUpdate
End Sub
Can someone PLEASE HELP ME ??????
Why is this not working as it is intended to work ??????????
Please help me out, as I have been working on this for the whole week and still can't get it to work !!
Thanks a lot !
Maneesh
maneeshmassey at gmail dot com
Last edited: