Re: Cascading Combo boxes using CASE command



Hi Agnelo
you need the correct syntax to 'talk' to the subform.
The name of the subform control is important.
A subform is always inside a subform control on the main form.
The name of the subform control can be, and often is, different from the
name of the subform inside it.

To talk to cboCity when it is on the subform you use syntax like this:
Me.[NameOfSubformControl].Form.cboCity
instead of just cboCity

Code something like this:

Private Sub cboCountry_AfterUpdate()
On Error Resume Next
Dim strTableName as String

Select Case cboCountry.Value
Case "France"
strTableName = "tblFrance"
Case "United Kingdom"
strTableName = "tblUnitedKingdom"
Case "United States"
strTableName = "tblUnitedStates"
End Select

Me.[NameOfSubformControl].Form.cboCity.RowSource = strTableName

End Sub


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


"Agnelo Fernandes" <AgneloFernandes@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:9BD4E04B-3FB8-4255-9E92-7147806BD166@xxxxxxxxxxxxxxxx
I tried setting up a cascading combo box between countries and cities i.e
based on the country u select , you can view the appropriate cities in the
other combo box.
I tried using CASE command in 'after update' of country combo box:

Private Sub cboCountry_AfterUpdate()
On Error Resume Next
Select Case cboCountry.Value
Case "France"
cboCity.RowSource = "tblFrance"
Case "United Kingdom"
cboCity.RowSource = "tblUnitedKingdom"
Case "United States"
cboCity.RowSource = "tblUnitedStates"
End Select
End Sub

This works fine but now I need 'cities' combo box to be in SubForm. So
based
on the option I select in Countries [on MainForm] I should get the
appropriate cities [on SubForm] by using CASE function...Any help


.



Relevant Pages

  • Re: Cascading Combo boxes using CASE command
    ... 'cities' based on the code u gave below. ... Dim strTableName as String ... you need the correct syntax to 'talk' to the subform. ... Private Sub cboCountry_AfterUpdate ...
    (microsoft.public.access.forms)
  • Re: Cascading Combo boxes using CASE command
    ... Countries, Cities and Colleges. ... guess the error is in addressing the combo in Subform. ... Private Sub Country_AfterUpdate ... Dim strTableName as String ...
    (microsoft.public.access.forms)
  • Re: Cascading Combo boxes using CASE command
    ... The name of the subform control is important. ... Dim strTableName as String ... Case "United Kingdom" ... cboCity.RowSource = "tblUnitedKingdom" ...
    (microsoft.public.access.forms)
  • Re: Cascading Combo boxes using CASE command
    ... 'cities' based on the code u gave below. ... Dim strTableName as String ... you need the correct syntax to 'talk' to the subform. ... Private Sub cboCountry_AfterUpdate ...
    (microsoft.public.access.forms)
  • Re: Need help with duplicates in form text boxes
    ... I'm reading the first set of directions, and under the *TechTasks*, it says, ... You need to use a main form and subform ... create a subform control on you main form using the toolbox (Cancel the ...
    (microsoft.public.access.forms)

Loading