By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,990 Members | 1,741 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,990 IT Pros & Developers. It's quick & easy.

Problem with report filter

P: 8
I set up a form for searching criteria and pass the searching result to a report. On this report there is an unbound text box (=[Report].Filter) and shows the searching criteria. It works fine when searching criteria is NOT NULL. But when Seaching criteria is Null, it will show some incorrect default filter.

I think the problem might be solved by using IIF( Report.filteron, Report.filter, Null). But I don't know how to set Report.filteron=True.

Here is my code to open the report
----------------------------------------------------------------------------------------------------------
Private Sub test_Click()
If Me.FilterOn Then
DoCmd.OpenReport "MyReport", acViewPreview, , Me.Filter
Else
DoCmd.OpenReport "My Report", acViewPreview
End If
End Sub
---------------------------------------------------------------------------------------------------------

Thanks a lot for your help.
Dec 6 '06 #1
Share this Question
Share on Google+
7 Replies


nico5038
Expert 2.5K+
P: 3,072
The report's FilterOn will be set to True by Access when opening the report with the criteria. When they are missing the FilterOn will be False.

Your code looks like the code I use in similar cases, what goes wrong ?

Just make sure that you didn't create a filter in the designmode and use no Null but:
=IIF( Report.filteron, Report.filter, "")

Nic;o)
Dec 6 '06 #2

P: 6
The report's FilterOn will be set to True by Access when opening the report with the criteria. When they are missing the FilterOn will be False.

Your code looks like the code I use in similar cases, what goes wrong ?

Just make sure that you didn't create a filter in the designmode and use no Null but:
=IIF( Report.filteron, Report.filter, "")

Nic;o)
This report would fit nicely into an application I am doing, but I would like to know how to create the form and pass the results to a report
Thanks
Dec 6 '06 #3

nico5038
Expert 2.5K+
P: 3,072
Bit confusing to have two questionners in one Q.
Best would be to post a new question to keep the replies clear.
The posted code by the questioner is placed behind a form that has the ability being filtered e.g. by using the right-click popup menu.
The filter button will look pressed when a filter is active and the form's Filter property will hold a string like "[ordernumber]=12345".
Such a filter can be passed to a report straight away.

Personally I use in general a datasheet subform and pass the filter of such a subform to a report by a button press. Check the filter samples at www.geocities.com/nico5038

Nic;o)
Dec 6 '06 #4

NeoPa
Expert Mod 15k+
P: 31,471
This report would fit nicely into an application I am doing, but I would like to know how to create the form and pass the results to a report
Thanks
SaratogaJoe,

Please post a new thread if you have a question.
Hi-jacking someone else's thread is frowned upon in these forums as it makes the job of helping more difficult.

MODERATOR.
Dec 6 '06 #5

NeoPa
Expert Mod 15k+
P: 31,471
I set up a form for searching criteria and pass the searching result to a report. On this report there is an unbound text box (=[Report].Filter) and shows the searching criteria. It works fine when searching criteria is NOT NULL. But when Seaching criteria is Null, it will show some incorrect default filter.

I think the problem might be solved by using IIF( Report.filteron, Report.filter, Null). But I don't know how to set Report.filteron=True.

Here is my code to open the report
----------------------------------------------------------------------------------------------------------
Private Sub test_Click()
If Me.FilterOn Then
DoCmd.OpenReport "MyReport", acViewPreview, , Me.Filter
Else
DoCmd.OpenReport "My Report", acViewPreview
End If
End Sub
---------------------------------------------------------------------------------------------------------

Thanks a lot for your help.
As Nico says, there isn't a better way than what you already use.
Like you, I feel there aught to be but I've never found one :(.
Dec 6 '06 #6

P: 8
Hi, Nico,
Thanks for your reply. I tried to use IIF as you suggested. However, it won't show any criteria evenif there is some searching criteria. So I guess the Report.FilterOn is False. What's wrong? Very confused.
Thanks again for your contribution.

The report's FilterOn will be set to True by Access when opening the report with the criteria. When they are missing the FilterOn will be False.

Your code looks like the code I use in similar cases, what goes wrong ?

Just make sure that you didn't create a filter in the designmode and use no Null but:
=IIF( Report.filteron, Report.filter, "")

Nic;o)
Dec 7 '06 #7

NeoPa
Expert Mod 15k+
P: 31,471
Do you have controls on your form called 'Filter' and 'filterOn'?
If not then you won't have anything to refer to.
Tell us what you do have and we can see if we can help with more detail.
Remember, we can only use any details you've already told us about. Otherwise we have to refer to things generically (like Report. etc). Does that make sense?
Dec 7 '06 #8

Post your reply

Sign in to post your reply or Sign up for a free account.