Re: Cascading Combo boxes using CASE command
- From: "Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx>
- Date: Fri, 3 Oct 2008 13:02:46 -0400
Did you try it? Did it work?
I may be reading too much into your variable names, but if you've actually
got tables named "Tbl_London_college", "Tbl_Amsterdam_college" and
"Tbl_Sydney_college", odds are your design is incorrect.
You should have one table that contains all of the colleges, with a field
indicating the city to which the college is linked. Your RowSource would
then be a query with an appropriate WHERE clause, and you wouldn't have to
go through this machinations.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Agnelo Fernandes" <AgneloFernandes@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:0A5F54D5-0861-48B5-9F21-06EF0821614E@xxxxxxxxxxxxxxxx
Hi Jeanette,
I have sorted that out - combo cascading from 'countries'[main form] to
'cities' [subform] based on the code u gave below.
Now I need to combo cascade 'cities' [sub form] to 'Colleges' [sub form].
Could I use the same code below as long as I indicate that 'cities' and
'colleges' are Sub Form eg:
Private Sub cboCity_AfterUpdate()
On Error Resume Next
Dim strTableName as String
Select Case cboCity.Value
Case "London"
strTableName = "Tbl_London_college"
Case "Amsterdam"
strTableName = "Tbl_Amsterdam_college"
Case "Sydney"
strTableName = "Tbl_Sydney_college"
End Select
Me.[NameOfSubformControl].Form.cboCollege.RowSource = strTableName
End Sub
Will this work?
"Jeanette Cunningham" wrote:
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
.
- Follow-Ups:
- Re: Cascading Combo boxes using CASE command
- From: Agnelo Fernandes
- Re: Cascading Combo boxes using CASE command
- References:
- Cascading Combo boxes using CASE command
- From: Agnelo Fernandes
- Re: Cascading Combo boxes using CASE command
- From: Jeanette Cunningham
- Re: Cascading Combo boxes using CASE command
- From: Agnelo Fernandes
- Cascading Combo boxes using CASE command
- Prev by Date: Form in Add mode with ODBC Table?
- Next by Date: If Form Field is populated, generate an additional report
- Previous by thread: Re: Cascading Combo boxes using CASE command
- Next by thread: Re: Cascading Combo boxes using CASE command
- Index(es):
Relevant Pages
|
Loading