Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / April 2005

Tip: Looking for answers? Try searching our database.

Report Filter Via a Form? Help?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brook - 29 Apr 2005 02:20 GMT
I have a form to filter a my rptinventory:

everything is working fine, I set my properties and set the filter and the
report filters properly, but what I sould like to do, is on the "Clear"
function it clears my Filter properties, but I would like the clear to also
clear and return the report to original format with no filters?

 Any suggestions?

Here is my coding for my frminventorysearch

Begin Code:

Private Sub Command28_Click()

Dim strSQL As String, intCounter As Integer
   'Build SQL String
   For intCounter = 1 To 5
     If Me("Filter" & intCounter) <> "" Then
       strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " & " =
" & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " And "
     End If
   Next

   If strSQL <> "" Then
       'Strip Last " And "
       strSQL = left(strSQL, (Len(strSQL) - 5))
       'Set the Filter property
       Reports![rptInventory].Filter = strSQL
       Reports![rptInventory].FilterOn = True
   Else
       Reports![rptInventory].FilterOn = False
   End If

End Sub

Private Sub Command29_Click()

   Dim intCouter As Integer

   For intCouter = 1 To 5
       Me("Filter" & intCouter) = ""
   Next

End Sub

Private Sub Command30_Click()
DoCmd.Close acForm, Me.Form.Name
End Sub

Private Sub Form_Close()
DoCmd.Close acReport, "rptInventory"
DoCmd.Restore
End Sub

Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenReport "rptInventory", A_PREVIEW
DoCmd.Maximize
End Sub

End Code *****
Duane Hookom - 29 Apr 2005 03:17 GMT
In over 10 years of creating Access reports, I have never set a filter
property of a report like this. I create a filter string/expression prior to
opening the report and use the strSQL in the DoCmd.OpenReport method like:

Dim strSQL as String, intCounter As Integer
For intCounter....

Next
DoCmd.OpenReport "rptYourReport", acPreview, , strSQL

Your strSQL ends up as the filter of the report. There is nothing to clear.

Signature

Duane Hookom
MS Access MVP

>I have a form to filter a my rptinventory:
>
[quoted text clipped - 58 lines]
>
> End Code *****
Brook - 29 Apr 2005 03:28 GMT
Thanks Duane,

 Do you think that  I have poor design? B/c it works really well, I have my
form with 5 different (cbobox)  filter options, and I can choose one or all
of them to filter my report.

 its not a big deal if I can't return to the original state of the form
(with no filter), I was just wondering if it was possible and it might be
nice if it could be done.

Thanks,

Brook

> In over 10 years of creating Access reports, I have never set a filter
> property of a report like this. I create a filter string/expression prior to
[quoted text clipped - 70 lines]
> >
> > End Code *****
Duane Hookom - 29 Apr 2005 04:15 GMT
I am somewhat surprised that the filter property is retained without a
"save" command in there. I suppose you could set the filter to "" in the On
Close event of the report.

Signature

Duane Hookom
MS Access MVP

> Thanks Duane,
>
[quoted text clipped - 91 lines]
>> >
>> > End Code *****
Brook - 29 Apr 2005 04:34 GMT
Duane,

The filter is an "on the fly " when I open my frminventorysearch, it opens
my rptinventory, when in turn, when I choose my filter options, will filter
the report on the fly, I don't save the filter options ... its my option to
search my 10,000 plus records ..

 

Do you understand?

> I am somewhat surprised that the filter property is retained without a
> "save" command in there. I suppose you could set the filter to "" in the On
[quoted text clipped - 95 lines]
> >> >
> >> > End Code *****
Duane Hookom - 30 Apr 2005 03:43 GMT
I don't understand why you don't just create a "where" clause and use it in
the DoCmd.OpenReport method.

Signature

Duane Hookom
MS Access MVP

> Duane,
>
[quoted text clipped - 114 lines]
>> >> >
>> >> > End Code *****
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.