I have a form which contains 2 listboxes. List1 displays all the states. List2 is supposed to display all the counties for the selected state in list1. In the init event of the form I have this code:
lcStateName = ALLTRIM(thisform.list1.Value)
SELECT stateid
LOCATE FOR state = lcStateName
lnStateID = StateID
lcRowSource = 'SELECT county From countyids '
lcRowSource = lcRowSource + 'WHERE (stateID = lnStateID) INTO CURSOR crList'
WITH Thisform.list2
.RowSource = lcRowSource
.ListIndex = 1
ENDWITH
In the Valid event of list1 I have this code:
lcStateName = ALLTRIM(this.Value)
SELECT stateid
LOCATE FOR state = lcStateName
lnStateID = StateID
Thisform.list2.Requery()
The code almost works, except when the user clicks on a state in list1, list2 is populated with the correct counties then blinks and is populated by ALL counties in the table.
Any help would be appreciated.
-Kevin
lcStateName = ALLTRIM(thisform.list1.Value)
SELECT stateid
LOCATE FOR state = lcStateName
lnStateID = StateID
lcRowSource = 'SELECT county From countyids '
lcRowSource = lcRowSource + 'WHERE (stateID = lnStateID) INTO CURSOR crList'
WITH Thisform.list2
.RowSource = lcRowSource
.ListIndex = 1
ENDWITH
In the Valid event of list1 I have this code:
lcStateName = ALLTRIM(this.Value)
SELECT stateid
LOCATE FOR state = lcStateName
lnStateID = StateID
Thisform.list2.Requery()
The code almost works, except when the user clicks on a state in list1, list2 is populated with the correct counties then blinks and is populated by ALL counties in the table.
Any help would be appreciated.
-Kevin