filtering a report form a form

G

Guest

Hi,

I have a form that I put filters on, and I want to print a report based on
this filtered form. I have the report created, but can't figure out how to
get the filter from the form to the report.

TIA
 
G

Guest

Use the Where argument of the OpenReport method. You should be able to read
the Filter proprty of the form and use it in the Where argument of the
OpenReport
 
G

Guest

I am trying to set up a button on my toolbar that will allow me to do this.
I am not sure of how to do this?

Thanks
 
G

Guest

I wouldn't know how to do that with a tool bar button. I would use a command
button on the form and put the code in the Click event.
 
G

Guest

I would, but this is being displayed in datasheet view normally, and I am
trying to get around the person having to change views just to print the
report. Maybe a floating form that can be psoitioned up in the toolbar area
so it looks like part of the toolbar?
 
G

Guest

I would create a form with a sub form and have your datasheet as the source
of the sub form. Then you can put any controls on the main form you need
without having to switch views.
 
G

Guest

OK, I did what you said, but it is still not filtering properly. Do I need
to change the code to point to the subforms filter? And, if so, how. the
subforms name is Current TB subform.

Thanks
 
G

Guest

Yes, you do have to change it to reference the subform's filter. The syntax is

frm!frmsubtaskvalidation.form.filter

Forms!FormName!SubFormName.Form.Filter
 
G

Guest

A million thank yous. It worked like a dream. THis has been driving me nuts
for months.
 
G

Guest

Not to worry, I have been nuts for year :)

Cyberwolf said:
A million thank yous. It worked like a dream. THis has been driving me nuts
for months.
--
James Gaylord
Finder of Paths, Hunter of Prey
Ghost of the Night, Shadow of Day
The Wolf
 
G

Guest

OKay, now it seems that the filter doesn't always clear properly. i.e. I
leave the filtered report, then undo the filter on my subform. When I go
back to my report it is holding the value of the old filter and not showing
the entire unfiltered data. Do I need to clear the filter eachtime I leave
the report?
 
G

Guest

OK, I have tried everything I an think of to unfilter. Give me a hint on
how to do it. I tried using the reports on close event and doing me.filter =
false, me.filteron = false. I also tried the got focus event on my subform
to remove the foiltering with no luck.

HELP!!!!!!!!!!

a very frustrated novice programer (as if that isn't evident)
 
G

Guest

Here are the ones I tried

Private Sub Report_Close()

Me.Filter = False

End Sub

Private Sub Report_Close()

Me.FilterOn = False

End Sub

Private Sub Form_GotFocus()

Me.Filter = False

End Sub


Private Sub Form_GotFocus()

Me.FilterOn = False

End Sub

And here is the code that I use to open the filtered report.

Dim stDocName As String

stDocName = "rpt:75905 TB"
DoCmd.OpenReport stDocName, acPreview, , Forms![frm:75905 TB]![75905 tb
subform].Form.Filter
 
G

Guest

I have noted the problems with the methods you have tried. Here is a fix I
think will work:

stDocName = "rpt:75905 TB"
stWhere = Me![frm:75905 TB]![75905 tbsubform].Form.Filter
DoCmd.OpenReport stDocName, acPreview, , stWhere
Me![frm:75905 TB]![75905 tbsubform].Form.FilterOn = False

Cyberwolf said:
Here are the ones I tried
Here, you are addressing the Report's filter, not the Form's
Private Sub Report_Close()

Me.Filter = False

End Sub
Same as Above
Private Sub Report_Close()

Me.FilterOn = False

End Sub
This won't work because a form cannot accept focus if there are any controls
on the form capable of accepting the focus.
Private Sub Form_GotFocus()

Me.Filter = False

End Sub

Same as Above
Private Sub Form_GotFocus()

Me.FilterOn = False

End Sub

And here is the code that I use to open the filtered report.

Dim stDocName As String

stDocName = "rpt:75905 TB"
DoCmd.OpenReport stDocName, acPreview, , Forms![frm:75905 TB]![75905 tb
subform].Form.Filter

--
James Gaylord
Finder of Paths, Hunter of Prey
Ghost of the Night, Shadow of Day
The Wolf


Klatuu said:
Post back with the code that isn't working, please.
 

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