Never Hide
Registered User.
- Local time
- Today, 15:52
- Joined
- Dec 22, 2011
- Messages
- 96
Update different combo boxes based on what you select
Hi everyone, I'm new here and i hope I can explain my problem clearly enough fo everyone to understand.
I have a database with a few tables with Villages, Cities, States etc.(kind of states,I'm from Greece and I don't know all the equivalent terms but that's not the point
)
To simplify things I'll give an example with the City and State Tables :
State(id, Name)
City(id, Name, Parent_id, LAT, LON)
"Parent_id" is a Foreign Key that refairs to the State each city belongs to. The general idea for the tables is (id,name,paent_id) where parent_id refers to the "higher [FONT="]authority"(I hope that's not confusing
) for each case.
I have created a form in which I display in textboxes the LAT/LON info for each city.[/FONT][FONT="]
I have also created another combox "cboxState", which is linked to the State table and when i chose a State it limits the options of the cboxCity so you only select cities from that state.
I have may more tables in my database and I use the same idea in the form to move futher down the hierarchy
My Problems now:
Numbe1:
(For the sake of simplicity I'll refer to only 2 tables)
I would like to have the option to select a City and that to limit the displayed options of the cboxState to the State the selected city belongs to BUT without disabling the option to select a State and see the cities in that state.
So basically I want to be able to requery any combox depending on what choice i make
Numbe2:
Some cities "belong" directly to a state-if u will- and not to a municipality which in its turn "belong" to a state so in the "Parent_id" of the "City" table ot all recods have the same "type" of id. By that I mean that a City that "belongs" directly to a state will have a Parent_id which only has 4 numbers.A city that "belongs" to a municipality has a Parent_id with 6 numbers, and so on. So what I want to do is this: when the Parent_id of a city that is selected is 4 numbers long,cboxCity has to requery the cboxState.If it's 6 numbers long i want it to requery the cboxMunicipality.
What I've tried in the AfterUpdate even of cboxCity is this:
By the way I have set "Parent_id" as a text field
[/FONT]
Column(7) (starting the count from Column(0) for the 1st column)is the Column of the cboxCity that contains the "Parent_id".
Also at the "Bound Column" property I've chosen "0"
[FONT="] Unfortunately that doesn't work
Any suggestions/ideas are greatly [/FONT]appreciated
P.S. If you notice in some words missing "R"s ,excuse my stupid keyboard
Hi everyone, I'm new here and i hope I can explain my problem clearly enough fo everyone to understand.
I have a database with a few tables with Villages, Cities, States etc.(kind of states,I'm from Greece and I don't know all the equivalent terms but that's not the point
To simplify things I'll give an example with the City and State Tables :
State(id, Name)
City(id, Name, Parent_id, LAT, LON)
"Parent_id" is a Foreign Key that refairs to the State each city belongs to. The general idea for the tables is (id,name,paent_id) where parent_id refers to the "higher [FONT="]authority"(I hope that's not confusing
I have created a form in which I display in textboxes the LAT/LON info for each city.[/FONT][FONT="]
I have also created another combox "cboxState", which is linked to the State table and when i chose a State it limits the options of the cboxCity so you only select cities from that state.
I have may more tables in my database and I use the same idea in the form to move futher down the hierarchy
My Problems now:
Numbe1:
(For the sake of simplicity I'll refer to only 2 tables)
I would like to have the option to select a City and that to limit the displayed options of the cboxState to the State the selected city belongs to BUT without disabling the option to select a State and see the cities in that state.
So basically I want to be able to requery any combox depending on what choice i make
Numbe2:
Some cities "belong" directly to a state-if u will- and not to a municipality which in its turn "belong" to a state so in the "Parent_id" of the "City" table ot all recods have the same "type" of id. By that I mean that a City that "belongs" directly to a state will have a Parent_id which only has 4 numbers.A city that "belongs" to a municipality has a Parent_id with 6 numbers, and so on. So what I want to do is this: when the Parent_id of a city that is selected is 4 numbers long,cboxCity has to requery the cboxState.If it's 6 numbers long i want it to requery the cboxMunicipality.
What I've tried in the AfterUpdate even of cboxCity is this:
By the way I have set "Parent_id" as a text field
[/FONT]
Code:
Private Sub cboxCity_AfterUpdate()
If Len(cboxCity.Column(7))=4 Then
Me.cboxState.Requery
ElseIf Len(cboxCity.Column(7))=6 Then
Me.cboxMunicipality.Requery
End IF
End Sub
Also at the "Bound Column" property I've chosen "0"
[FONT="] Unfortunately that doesn't work
Any suggestions/ideas are greatly [/FONT]appreciated
P.S. If you notice in some words missing "R"s ,excuse my stupid keyboard
Last edited: