Print form/report with filter (1 Viewer)

georg7

Registered User.
Local time
Yesterday, 22:53
Joined
Sep 3, 2019
Messages
84
Hi there,
I want to print my form/table ("frm_all") with the filter I select but it won't work… may somebody have ideas?
I tried it with
Code:
Private Sub Befehl32_Click()
DoCmd.OpenForm "Bericht1", acPreview, , Me.Filter
End Sub
Sometimes it prints with filter and sometimes not.

On form "frm_all" I can filter due the Dropdowns. Now I want to print with the filters.


The attached DB is not the current db ist an older Version but it's no Problem.

Best regards
Georg
 

Attachments

  • Work.zip
    3.1 MB · Views: 144

Gasman

Enthusiastic Amateur
Local time
Today, 06:53
Joined
Sep 21, 2011
Messages
14,231
No point attaching a DB that is not the one with the problem.?
Who knows what the difference could be between them.? :(
 

mike60smart

Registered User.
Local time
Today, 06:53
Joined
Aug 6, 2017
Messages
1,908
Hi there,
I want to print my form/table ("frm_all") with the filter I select but it won't work… may somebody have ideas?
I tried it with
Code:
Private Sub Befehl32_Click()
DoCmd.OpenForm "Bericht1", acPreview, , Me.Filter
End Sub
Sometimes it prints with filter and sometimes not.

On form "frm_all" I can filter due the Dropdowns. Now I want to print with the filters.


The attached DB is not the current db ist an older Version but it's no Problem.

Best regards
Georg
Hi Georg

Best to stop and address the various problems you have

You should not be using Lookup Fields in your tables.
Google the Evils of Lookup Fields in Access Tables

Also if you attempt to Enforce Referential Integrity between tbl_Mitarbieter and tblGrupper you receive an error indicating that you have created a Parent Record with no related Child Record
 

georg7

Registered User.
Local time
Yesterday, 22:53
Joined
Sep 3, 2019
Messages
84
@Gasman There is no real difference they both work the same way. This one has just less data of users.

@mike60smart It's not my database I've to use it :/ I just edit things that are needed.
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:53
Joined
Sep 21, 2011
Messages
14,231
@Gasman There is no real difference they both work the same way. This one has just less data of users.

@mike60smart It's not my database I've to use it :/ I just edit things that are needed.
They might well work the same way, but who is to say the code is the same?
FWIW, I have hardly ever printed a form per record, I would use a report, but that is a personal preference.

How do you print the form.?
If I use File/Print after filtering the 3 records to one, I ended up with the same record, but three times.?
I I choose Selected records, then I get just the one.?

However from the navigation bar of each form frm_all shows 3 records all the time?
You are filtering sf_qry_all, not frm_all ? and that will show 1 of 1 if I choose NI ?
 

georg7

Registered User.
Local time
Yesterday, 22:53
Joined
Sep 3, 2019
Messages
84
Code is also the same just without some names and logos from the Company.
Okay, printing a report would be nice. How do I get a button that prints a rpeort with the filtered data of the form?
 

georg7

Registered User.
Local time
Yesterday, 22:53
Joined
Sep 3, 2019
Messages
84
Everytime I want to print the filtered datasets I'll get all datasets without a filter….
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:53
Joined
Sep 21, 2011
Messages
14,231
You use the Filter property of the subform.
Use that in the Open command for the report before you print it.


 

georg7

Registered User.
Local time
Yesterday, 22:53
Joined
Sep 3, 2019
Messages
84
So I'm add a button on form frm_all that opens a report ( "report1"). On Report1 should be a subform of sf_qry_all?
I'm sorry that I don't understand everything because english is not my main language...

Should it look like that?
Code:
Private Sub openReport1_Click()
    If Me.Filter = "" Then
        MsgBox "Apply a filter to the form first."
    Else
        DoCmd.OpenReport "Report1", acViewReport, , Me.Filter
    End If
End Sub
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:53
Joined
Sep 21, 2011
Messages
14,231
So I'm add a button on form frm_all that opens a report ( "report1"). On Report1 should be a subform of sf_qry_all?
I'm sorry that I don't understand everything because english is not my main language...

Should it look like that?
Code:
Private Sub openReport1_Click()
    If Me.Filter = "" Then
        MsgBox "Apply a filter to the form first."
    Else
        DoCmd.OpenReport "Report1", acViewReport, , Me.Filter
    End If
End Sub
Up to you to insist on a filter to print.?
Create a simple report using the Report wizard on the source of the data for sf_qry_all.

You could put the subform on the report (not something I have ever done. I keep forms with forms and reports with reports). Again personal choice.
 

georg7

Registered User.
Local time
Yesterday, 22:53
Joined
Sep 3, 2019
Messages
84
I think I'm to dumb….
I can select sf_qry_all with the wizard just the source of all datasets of sf_qry_all (qry_all).
Could you edit the db and Show me how it works?
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:53
Joined
Sep 21, 2011
Messages
14,231
I've added a report suffixed with 'with_subform' and one called rptqry_all.
You can adjust the latter to fit all the fields (or required fields).
Then use that filter argument to open either of the reports.

HTH
 

Attachments

  • test1.zip
    3.2 MB · Views: 134

georg7

Registered User.
Local time
Yesterday, 22:53
Joined
Sep 3, 2019
Messages
84
I don't get it to work….

Thank you for your effort!!!!!! I really appreciate it!!
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:53
Joined
Sep 21, 2011
Messages
14,231
Try the one with the 'with subform' first.
1597738897604.png
 

georg7

Registered User.
Local time
Yesterday, 22:53
Joined
Sep 3, 2019
Messages
84
But how does it filter? I want to select the filter at frm_all :/
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:53
Joined
Sep 21, 2011
Messages
14,231
You open the report with the filter you created for sf_qry_all
frm_all only holds the filter fields?

Here is a quick print button with the filter. You take it from here.
 

Attachments

  • test1.zip
    3.2 MB · Views: 196

georg7

Registered User.
Local time
Yesterday, 22:53
Joined
Sep 3, 2019
Messages
84
Thank you @Gasman !!!!!!!!
Can't thank you enough!
You really saved me. Appreciate all your effort !
 

georg7

Registered User.
Local time
Yesterday, 22:53
Joined
Sep 3, 2019
Messages
84
Wish you all the best and stay healthy/safe in those times!
 

Users who are viewing this thread

Top Bottom