Export a report with a filtered subform inside it

3gustavo

New member
Local time
Today, 18:17
Joined
Nov 16, 2021
Messages
12
Hi,

Can someone tell me how to filter a subform that is inside a report and export the report with the filtered subform in pdf, please?
 
Hi. Welcome to AWF!

How are you planning to filter the subreport?
 
Thank you.

I am planning to export the report (ID report) in pdf format with the filtered subform (subform) inside it by clicking in a button of another form (Me). The filter is based on the value of a textbox (txtbox) in that form.

Code:
Private Sub Command669_Click()

Dim report As String

report = "ID Report"

id = Forms("form").txtbox

DoCmd.OpenReport report, view:=acViewPreview, _
wherecondition:= Reports(report).subform.Form.Filter = "[ID] = '" & Me.id & "'", _
windowmode:=acHidden

DoCmd.OutputTo acOutputReport, report, acFormatPDF, , True

End Sub
 
It export the report without the filter. Is the code right?
First, let's verify... When you execute that code, it should open the report and leave it open (because I don't see where you're closing it). If so, review the report and let us know if the subform/subreport is actually filtered as you expected.
 
So, as asked in your other thread: Is the subform/subreport container control actually named "subform"? If not, then use the correct name.

Strongly advise not to use spaces nor punctuation/special characters in naming convention.
 
So, as asked in your other thread: Is the subform/subreport container control actually named "subform"? If not, then use the correct name.

Strongly advise not to use spaces nor punctuation/special characters in naming convention.
No, it is not the same situation. That's why I created two different threads...

Come on, man. Of course I am using the right name. You just can't know what it is because of something called confidentiality agreement, that's why I just put 'subform'.

You are not helping at all...
 
Hmm, I may have answered my own question. It looks like you're still trying to figure out how to filter the subreport. Is that correct?
It is. I can make the way you like to do. Do you know a code that export a report with a filtered subform/subreport in it, please?
 
It is. I can make the way you like to do. Do you know a code that export a report with a filtered subform/subreport in it, please?
I didn't correct your original code, because I think it should work as is. So, we just need to make sure you are filtering the subreport properly. Once it is, the OutputTo should work fine. By the way, is the subreport using the Linked Master/Child Fields? If so, would filtering the main report not enough to also filter the subreport?
 
You are not helping at all...

You should have mentioned that you have replaced a confidential name with "subform" in your original posting of the question..

That's why you are getting feedback which does not feel like help, because your original brief was lacking in clarity and conciseness.
 
I didn't correct your original code, because I think it should work as is. So, we just need to make sure you are filtering the subreport properly. Once it is, the OutputTo should work fine. By the way, is the subreport using the Linked Master/Child Fields? If so, would filtering the main report not enough to also filter the subreport
That helped me a lot. Thank you so much.
 
Primarily, I was not talking to you.

......... The truth is that you and June7 are lacking so much knowledge and having so much arrogance that, by the moment you truly believe you understood the situation, you start questioning my code with ridiculous points (which shows your limited knowledge) as if you understood what is going on and as if you knew the only solution for the problem.

You are lucky I'm not a moderator. Otherwise you would have been banned or at least warned.
The funny thing is that someone who is not even able to filter a sub report, is addressing @June7 & @Uncle Gizmo limited knowledge.
You're new and apparently don't know, but for your information they are two of best Access developers here.
 
Last edited:
Only things I can get to work for PrintPreview is setting Filter and FilterOnLoad properties in form design.

Filter: [ID]= Forms![ID Form]![Person ID]
FilterOnLoad: Yes

Or dynamic parameterized query as form's RecordSource.

Also wonder if Master/Child Links should be adequate to properly filter subform.

@Sun_Force, thank you for the kudos and support.

Don't claim to be perfect nor always grasp core nature of issue. Won't apologize for asking questions and making suggestions even if they aren't quite on mark.
 
Last edited:
That helped me a lot. Thank you so much.
Does that mean that you added the missing Master/Child link to resolve the problem? I couldn't tell if you were being snarky. Just FYI, "snarky" will get you ignored by the people who actually can help you. It takes a lot more to get yourself banned than being snarky. We are not snowflakes here.
 
That's why you are getting feedback which does not feel like help, because your original brief was lacking in clarity and conciseness.

BTW, I should have explained, we don't expect clarity and conciseness in the questions posted here, because we know that it's difficult to explain the issue.

We are all very experienced at asking questions to ferret out the underlying issue/s, questions that enable us to home in and offer a solution.

I made this post because I think it's important that any "browsing" person should not get the impression they need to make a perfect post. That is definitely not the case!
 

Users who are viewing this thread

Back
Top Bottom