Filter from form to report (1 Viewer)

georg7

Registered User.
Local time
Today, 00:45
Joined
Sep 3, 2019
Messages
84
Good morning guys,
I've my form where I get my data from my query. on the form I set a filter to select my wanted data(red circle). Is it possible to get the filter to my report that I can print it ? Printing forms is just annoying and it Looks Pretty ugly.

Or are there other ways to get the printed form more like "high quality"?

Appreciate your help!
Best regards georg7
 

Attachments

  • code.PNG
    code.PNG
    21.7 KB · Views: 81
  • filter.PNG
    filter.PNG
    25.3 KB · Views: 71
  • report.PNG
    report.PNG
    13.7 KB · Views: 72

isladogs

MVP / VIP
Local time
Today, 08:45
Joined
Jan 14, 2017
Messages
18,221
Yes. You can filter reports in exactly the same types of ways as you filter forms.
For example you can use a 'where condition' in your report record source based on the form filter value.
See DoCmd.OpenReport method

Or you can use the OpenArgs property
 

georg7

Registered User.
Local time
Today, 00:45
Joined
Sep 3, 2019
Messages
84
I tried the DoCmd.OpenReport method but I won't work.(you can see it on Code.png)
It always prints the full form data not the datas that I've filtered.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 08:45
Joined
Feb 19, 2013
Messages
16,612
looks like you have a form/subform arrangement with the button on the main form, so your code (which for future reference and clarity, please copy/paste to the thread using the insert - code option on the post ribbon) needs to be something like

docmd.openreport "myReport",,,mysubformname.form.filter
 

isladogs

MVP / VIP
Local time
Today, 08:45
Joined
Jan 14, 2017
Messages
18,221
Georg
You used the filter name argument NOT the where condition.
As CJL siad, something like this should work

Code:
DoCmd.OpenReport "ReportName", , , "FieldName = '" & Forms!FormName.ControlName & "'"
 

georg7

Registered User.
Local time
Today, 00:45
Joined
Sep 3, 2019
Messages
84
Thank you guys for your help but I don't mean the tipical filter. In Germany this(Picture) is also called a Filter but i think ist more like a select.I can pick the data that I want and the rest will be hidden.

I think that there is no way to get it to my report?
 

Attachments

  • Inkedawwww_LI.jpg
    Inkedawwww_LI.jpg
    742.9 KB · Views: 72

theDBguy

I’m here to help
Staff member
Local time
Today, 00:45
Joined
Oct 29, 2018
Messages
21,473
Thank you guys for your help but I don't mean the tipical filter. In Germany this(Picture) is also called a Filter but i think ist more like a select.I can pick the data that I want and the rest will be hidden.

I think that there is no way to get it to my report?
Hi. Have you tried what CJ suggested? Just curious...
 

CJ_London

Super Moderator
Staff member
Local time
Today, 08:45
Joined
Feb 19, 2013
Messages
16,612
your picture shows one of the ways that records can be filtered from a datasheet, as you tick and untick it updates the filter property. If you were to right click on one of the fields below you will get other ways of filtering.

It is now not clear to me what you want - you originally said you wanted a report based on the filter of the form which is perfectly doable as already explained. What you now seem to be asking is how to get the filter creation functionality of a datasheet into a report. To do that, you would need to use a datasheet subreport (create your subreport control on your report, and populate the sourceobject with Query.myQuery or Table.myQuery or Form.myForm (where myForm is a datasheet).
 

georg7

Registered User.
Local time
Today, 00:45
Joined
Sep 3, 2019
Messages
84
Thank you CJ!
I'm really sorry for the misunderstanding.
I appreciate your help.
I think my Access skills are not good enough to create something like that because I'm a newbie.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 08:45
Joined
Feb 19, 2013
Messages
16,612
no problem, happy to help. Good luck with your project
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 03:45
Joined
May 21, 2018
Messages
8,529
@georg7
This does what you want and the code is simple
 

Attachments

  • FilterReport.zip
    77.1 KB · Views: 85

Users who are viewing this thread

Top Bottom