Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Microsoft: Access Forms FAQ

Form Basics

How do I filter combobox based on other combobox/control value by Hasu
Posted: 22 Jul 03 (Edited 4 May 05)

Mostly access user having problem to filter/fill combobox based on other combobox/control value. There is a simple way to do this.

combobox/control: combobox/control: first control that has value (combox1)
combobox: second control as combobox that will fill by first control value (combox2)

Write code in to afterupdate event of combobox/control to set combobox rowsource.
Set combobox/control value to null
Set combobox rowsource properties with SQL statement, the SQL statement will have criteria in where clause to filter record from table.
And requery combobox to get up to date data.

If your form has more than one combobox that depends upon successive combobox, you can continue below process for each combobox except last combobox. And keep adding combobox value into your SQL where clause to filter unique records.

For Example,

Private Sub combox1_AfterUpdate()

combobox2= Null
combobox3= Null

combox2.RowSource = "SELECT DISTINCT Feild2 FROM Table1 " & _
" WHERE Field1='" & combox1 & "'"

End Sub

Private Sub combox2_AfterUpdate()

combobox3= Null

combox3.RowSource = "SELECT DISTINCT Feild3 FROM Table1 " & _
      " WHERE Field1='" & combox1 & "' AND Field2='" & combox2 & "'"

End Sub

I hope this FAQ will help users.

Back to Microsoft: Access Forms FAQ Index
Back to Microsoft: Access Forms Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close