ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   cascading 3 cboboxes (https://www.excelbanter.com/excel-programming/373573-cascading-3-cboboxes.html)

Joanne[_4_]

cascading 3 cboboxes
 
I have these two cboboxes in my app and the 'cascading' works great.
What I need is the coding for ThirdCboBox that would be using both of
the first two cboboxes to limit the choices available to the userin
the third cbobox , but I don't know how to construct the sql statement
to include two 'limit' criterias in one statement.
Please help me with this - I sure appreciate your time and expertise,
as always. You guys have made this project a fun and successful deal
for me.

First CboBox
Private Sub cboCoName_AfterUpdate()
Me!cboLocation.RowSource = "select tblmain.[location] from tblmain
where tblmain.[CoName] ='" & Me!cboCoName & "'"
Me.cboCoName.Requery
End Sub


SecondCboBox
Private Sub cboLocation_AfterUpdate()
Me!cboStreet.RowSource = "select tblmain.[street] from tblmain
where tblmain.[Location] ='" & Me!cboLocation & "'"
Me.cboStreet.Requery
End Sub


Joanne[_4_]

cascading 3 cboboxes
 
As I look at this and try to figure it out it occurs to me that I
don't need code for the third cbobox. I think I need to extend the sql
statement in the second cboBox.

I tried this, without success :-(

SecondCboBox
Me!cboStreet.RowSource = "select tblmain.[street] from tblmain
where tblmain.[Location] ='" & Me!cboLocation & "'" And "select
tblmain.[street] from tblmain where tblmain.[CoName] = '"&
Me!cboCoName & "'"

What I am doing is first choose a Company, then the city they are in,
then their street (all from cboboxes). I can get the Company and the
particular city I want from my tables, but when I choose a street, I
get all streets from all companies in the city I chose. I would like
to get only the street(s) that are relevant to the company and city I
chose.

TIA
Joanne



Joanne wrote:

I have these two cboboxes in my app and the 'cascading' works great.
What I need is the coding for ThirdCboBox that would be using both of
the first two cboboxes to limit the choices available to the userin
the third cbobox , but I don't know how to construct the sql statement
to include two 'limit' criterias in one statement.
Please help me with this - I sure appreciate your time and expertise,
as always. You guys have made this project a fun and successful deal
for me.

First CboBox
Private Sub cboCoName_AfterUpdate()
Me!cboLocation.RowSource = "select tblmain.[location] from tblmain
where tblmain.[CoName] ='" & Me!cboCoName & "'"
Me.cboCoName.Requery
End Sub


SecondCboBox
Private Sub cboLocation_AfterUpdate()
Me!cboStreet.RowSource = "select tblmain.[street] from tblmain
where tblmain.[Location] ='" & Me!cboLocation & "'"
Me.cboStreet.Requery
End Sub



Joanne[_4_]

cascading 3 cboboxes
 
Sorry please excuse this post. I put it in the wrong group. Meant to
use the access programming group.

Joanne wrote:

As I look at this and try to figure it out it occurs to me that I
don't need code for the third cbobox. I think I need to extend the sql
statement in the second cboBox.

I tried this, without success :-(

SecondCboBox
Me!cboStreet.RowSource = "select tblmain.[street] from tblmain
where tblmain.[Location] ='" & Me!cboLocation & "'" And "select
tblmain.[street] from tblmain where tblmain.[CoName] = '"&
Me!cboCoName & "'"

What I am doing is first choose a Company, then the city they are in,
then their street (all from cboboxes). I can get the Company and the
particular city I want from my tables, but when I choose a street, I
get all streets from all companies in the city I chose. I would like
to get only the street(s) that are relevant to the company and city I
chose.

TIA
Joanne



Joanne wrote:

I have these two cboboxes in my app and the 'cascading' works great.
What I need is the coding for ThirdCboBox that would be using both of
the first two cboboxes to limit the choices available to the userin
the third cbobox , but I don't know how to construct the sql statement
to include two 'limit' criterias in one statement.
Please help me with this - I sure appreciate your time and expertise,
as always. You guys have made this project a fun and successful deal
for me.

First CboBox
Private Sub cboCoName_AfterUpdate()
Me!cboLocation.RowSource = "select tblmain.[location] from tblmain
where tblmain.[CoName] ='" & Me!cboCoName & "'"
Me.cboCoName.Requery
End Sub


SecondCboBox
Private Sub cboLocation_AfterUpdate()
Me!cboStreet.RowSource = "select tblmain.[street] from tblmain
where tblmain.[Location] ='" & Me!cboLocation & "'"
Me.cboStreet.Requery
End Sub





All times are GMT +1. The time now is 12:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com