change select query conditions from inside form

  • Thread starter ricardozelaya via AccessMonster.com
  • Start date
R

ricardozelaya via AccessMonster.com

Is there any way to setup a combo/list box with zip codes so that when I
select a zip code, the query the form is based on only displays the records
corresponding to that zip code.

I know I can display the zip codes that I want by changing the zip code field
in query design view before opening the form.
 
A

Allen Browne

You can apply a filter to the form.

The example below assumes you have a Text field named Zip, and you want to
filter the form using an unbound combo named cboFilterZip:

Private Sub cboFilterZip_AfterUpdate()
If Not IsNull(Me.cboFilterZip) then
If Me.Dirty Then Me.Dirty = False 'save first.
Me.Filter = "[Zip] = """ & Me.cboFilterZip & """"
Me.FilterOn = True
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top