Restrict view using a combo box

K

Keith

Is there any way that I can limit the data that a for shows based on a combo
box on the form?

I want the user to select a year from the combo box so they only see that
year's data. I also have a-z and all buttons along the bottom of the form to
allow easy location of data. I need this to contine to work as well.

I know you can use the query by form on the toolbar, but the people who will
be using the form will be accessing it through runtime access so that option
will not be available.
 
S

Stefan Hoffmann

hi Keith,
Is there any way that I can limit the data that a for shows based on a combo
box on the form?
Create a form with a combobox for your year selection called cboYear.
Open the form and select a year.
Use the following SQL structure for your query and run it:

SELECT *
FROM TableName
WHERE Year(DateTimeField) = Forms("FormName").cboYear.Value

(the form with the combobox must be still open)
I want the user to select a year from the combo box so they only see that
year's data. I also have a-z and all buttons along the bottom of the form to
allow easy location of data. I need this to contine to work as well.
Display the data using a subform. Use the on change event of the
combobox to requery the data:

Private Sub cboYear_OnChange()

frmSubform.Form.Requery

End Sub


mfG
--> stefan <--
 
K

Klatuu

A requery after every keystroke would certainly degrade performance. If the
Auto Expand property of the Combo is set to Yes, this won't be necessary, nor
will the buttons at the bottom of the form.
 
Top