Code to Filter on a form

  • Thread starter Thread starter elki.camacho
  • Start date Start date
E

elki.camacho

I have a form that searches a query based on zipcode. I then need to be
able to Filter the report by a selection. (it won't the the same each
time.its based on what populates by the ziocode search)

I can make a command button but can't get past this:

Private Sub Command12_Click()

Please help.
 
Use the report comand line, to pass the where condition

Assuming that zip code is text
Dim MyWhereCondition as String
MyWhereCondition = "ZipCodeFieldNameInTheTabel = '" &
Me.ZipCodeFieldNameInTheForm & "'"
docmd.OpenReport "reportName",,,MyWhereCondition

If zip code is number then
MyWhereCondition = "ZipCodeFieldNameInTheTabel = " &
Me.ZipCodeFieldNameInTheForm
 
Back
Top