Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RE: Problems filtering

Status
Not open for further replies.

angiew

Technical User
Jun 22, 2000
37
US
I have a form that is linked to a query.&nbsp;&nbsp;The form has a bound text box that will be used to filter by input.&nbsp;&nbsp;After the filters have been made (multiple filters will be allowed), the user will click a button to preview a report on the filtered information.&nbsp;&nbsp;Ultimately there will be many text boxes on this form to filter with.&nbsp;&nbsp;Right now, I only have one text box on the form because I am testing how it works.&nbsp;&nbsp;I tried it once, and the report did not show only the filtered records.&nbsp;&nbsp;I then realized the Filter On Property was set to &quot;No&quot;.&nbsp;&nbsp;I set it to &quot;Yes&quot; and tried again.&nbsp;&nbsp;The report produced the filtered records.&nbsp;&nbsp;Then, I went back to the form to filter with a different choice.&nbsp;&nbsp;After I applied to filter, I clicked the button to preview the report, and it did not work.&nbsp;&nbsp;The filter information did not carry over to the report.&nbsp;&nbsp;Does anyone know why?<br><br>Angie Wenzel<br>
 
Hiya Angie,<br><br>I'm not sure why what you're doing is not working, but I can offer how I solved similar needs in my apps.<br><br>The data entry/edit form has a button to call the report.&nbsp;&nbsp;In the report, the OnOpen event... from my archives, I've pulled this prior response from Jeff Wilson...the only difference is the coding is for opening a form, but the principal and solution is the same.<br><br>HTH,<br>Drew<br><br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Jun 23, 06:49 PM<br>Jeff Wilson (in response to Matt Trossen) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Message 2 of 4<br>Re: How do I create a criteria based query to reference?<br>Matt, what I've done in this situation is to create my main form (that form that <br>contains the basic information) and have it open a search criteria form <br>(frmSearchCriteria). This is done through the OnOpen event of the main form, as <br>Private Sub Form_Open(Cancel As Integer) <br>DoCmd.Maximize <br>DoCmd.OpenForm &quot;frmSearchCriteria&quot;, , , , , acDialog, (Me.Name) End Sub <br>The frmSearchCriteria contains checkboxes that turn search fields on and off, <br>possibly radio buttons, all depending how who want to search. But it basically <br>does exactly what you - develops a filter statement for the main form. <br>For instance, it might test if a checkbox is turned on and, if so, build a WHERE <br>filter string such as <br>strWhere = strWhere & &quot; AND (Area = &quot;&quot;&quot; & cboArea & &quot;&quot;&quot;)&quot; &lt;--cboArea is text <br>strWhere = strWhere & &quot; AND (CardDate &lt;= #&quot; & cboAuditedTo & &quot;#)&quot; <br>&lt;--cboAuditedTo is a date <br>As you can see, you have to a little careful in building the filter string <br>because text has to enclosed in quotes, and dates have to be enclosed in # <br>signs. <br>Once you get to the end, you remove the beginning &quot; AND &quot; by performing If <br>Len(strWhere) &gt; 0 Then strwhere = Mid$(strWhere, 6) <br>Then you set the filter statement and return to the main form by Set frm = <br>Forms(Me.OpenArgs) <br>frm.Filter = strWhere <br>frm.FilterOn = True <br>DoCmd.Close acForm, Me.Name <br>HTH, <br>Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top