Have you ever wanted to have a second combo box (perhaps listing products) based on another combo box (perhaps listing companies)? Thus after the user chooses a company, he then sees only the products for that company in the second combo box.
For criteria in the 2nd combo box (and to get to the query design mode of the combo box click on the 3 dots just to the right of the combo box's RowSource property):
Like [Forms]![MyForm]![MyFirstComboBox]
And for the OnEnter property of the 2nd combo box:
=ctlRequery()
And in any module:
Public Function ctlRequery()
' Purpose: Use this in OnEnter property of a combobox that's based on another control
' that may have changed or based on records that may have changed
' since the form was first opened.
On Error GoTo Err_ctlRequery
' Dim var.
Dim ctl As Control
' Set var.
Set ctl = Screen.ActiveControl
' Requery control.
ctl.Requery
Exit Function
Err_ctlRequery:
Exit Function
End Function
For an example of dependent combo boxes you can download my sample invoices database currently at the link toward the bottom of http://www.bullschmidt.com/login.asp and then on the Invoices Dialog check out the Invoice # combo box which is based on the Rep # combo box.
J. Paul Schmidt, Freelance Access and ASP Developer
http://www.Bullschmidt.com/Login.asp - Database on the Web Demo
http://www.Bullschmidt.com/Access - Sample Access Invoices Database
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.