Print form/report with filter

georg7

Registered User.
Local time
Today, 15:05
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

No point attaching a DB that is not the one with the problem.?
Who knows what the difference could be between them.? :(
 
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
 
@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 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 ?
 
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?
 
Everytime I want to print the filtered datasets I'll get all datasets without a filter….
 
You use the Filter property of the subform.
Use that in the Open command for the report before you print it.


 
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
 
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.
 
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?
 
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

I don't get it to work….

Thank you for your effort!!!!!! I really appreciate it!!
 
Try the one with the 'with subform' first.
1597738897604.png
 
But how does it filter? I want to select the filter at frm_all :/
 
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

Thank you @Gasman !!!!!!!!
Can't thank you enough!
You really saved me. Appreciate all your effort !
 
Wish you all the best and stay healthy/safe in those times!
 

Users who are viewing this thread

Back
Top Bottom