Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 linked combo boxes, how do i reset the values in the second one?

Status
Not open for further replies.

martinrobson

Programmer
Jun 2, 2003
19
0
0
GB
Hi,

I have 2 combo boxes, the second one displays the correct data, depending on what is selected in the first one. The problem is that if i click on one value in box 1, then box 2 shows the correct data, but if i then decided to change my mind about what i chose in box 1 and change the value selected, then box 2 does not change its data accordingly and just keeps diplaying what it found originally.

Each combo box is populated by a query.

Would anyone know how to reset the value of the query that populates combo box 2 before each selection in box 1 is made?

I can give you the code if it would help.

Thanks,
Martin
 
in the AfterUpdate Event of Combo1, add

Combo2.Requery

PaulF
 
Thanks PaulF,

I tried that but unfortunately it hasnt worked here is the code im using.

Private Sub COMBO1_AfterUpdate()
Dim Db as DAO.Database
Dim qdf as DAO.QueryDef
Set db = CurrentDb()
Set qdf = db.QueryDefs("query1")
Dim StrSQL as String

Select Case COMBO1

Case Is "X"
StrSQL = " Select blah "
qdf.SQL = strSQL

Case Is "Y"
StrSQL = " Select blah "
qdf.SQL = strSQL

End Select

Set db = Nothing
Set qdf = Nothing

COMBO2.Requery

End Sub

Any ideas?

Thanks
 
Try something like this


Me.Combo2.Rowsource = "Select Blah From Blah"
Combo2.Requery

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top