Filter Query to save the report (1 Viewer)

Rania01

Member
Local time
Today, 08:28
Joined
Oct 9, 2021
Messages
59
Dear All,
How to create a filter on the Query to be able to save the report only showing data on form
Without filters all data will be save in one pdf file.
 

Attachments

  • Photo.png
    Photo.png
    41.6 KB · Views: 245

theDBguy

I’m here to help
Staff member
Local time
Today, 00:28
Joined
Oct 29, 2018
Messages
21,358
Hi. I'm not sure I understand your question. If you have a query with a criteria pointing to that form's textbox, then it would only show the records matching the value on the form.
 

Gasman

Enthusiastic Amateur
Local time
Today, 07:28
Joined
Sep 21, 2011
Messages
14,050
Use the form control value as the criteria for the report in the where argument of the openreport command
 

Rania01

Member
Local time
Today, 08:28
Joined
Oct 9, 2021
Messages
59
Use the form control value as the criteria for the report in the where argument of the openreport command
Dear Gasman,
When I klick on CMD all data wil be save as one Report. I Would like to save the report every claim ID as one pdf file
Could you please help me how to do that see example pdf file
 

Attachments

  • 1234562545 GLT.PDF
    193 KB · Views: 256
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 07:28
Joined
Sep 21, 2011
Messages
14,050
I think you mean each claim ID in it's own report?
For that I would use a recordset loop with whatever criteria you want, and inside that loop open the report with the recordset claim ID, and output to pdf.
I'm about to go to bed now, so if no-one else chips in. I will look for an example tomorrow.
 

jdraw

Super Moderator
Staff member
Local time
Today, 03:28
Joined
Jan 23, 2006
Messages
15,364
I don't understand your post/requirement? Like gasman, I think you are asking about a report for each ClaimID. But I need clarity on the requirement --suggest you try describing your need again.
 

Rania01

Member
Local time
Today, 08:28
Joined
Oct 9, 2021
Messages
59
I think you mean each claim ID in it's own report?
For that I would use a recordset loop with whatever criteria you want, and inside that loop open the report with the recordset claim ID, and output to pdf.
I'm about to go to bed now, so if no-one else chips in. I will look for an example tomorrow.
Dear Gasman,
Could you please look example, I can learn from it
Thank you in advance for your help
 

Gasman

Enthusiastic Amateur
Local time
Today, 07:28
Joined
Sep 21, 2011
Messages
14,050
Dear Gasman,
Could you please look example, I can learn from it
Thank you in advance for your help
You are not helping yourself here.
All that pdf shows is a page for what I assume is each claim ID with a blank page between them :(

Going on my assumption that you want one pdf report file for each claim id or some other criteria, see the code below.
This is from my very first Access DB and produces a report for each ship. The output can been seen here http://www.bibby-gazette.co.uk/ships.html

Your method should be similar if not the same.

Code:
Sub Print_All_Ships()
    Dim rs As DAO.Recordset
    Dim db As Database
    Dim stSQL As String, stDate As String, stDBpath As String, stFTPpath As String
    Dim stRptName As String, stParam As String, stLinkCriteria As String, stAlphabet As String, astAlpa(1, 26) As String
    Dim stStart As String, stEnd As String, iloop As Integer
    Dim iOKCancel As Integer

    ' GoTo rptalpha

    stRptName = "Main_by_Ship"
    Set db = CurrentDb
    ' Generate all the Ship reports
    ' GoTo rptleave:
    stDBpath = CurrentProject.Path & "\"
    stFTPpath = stDBpath & "Gazette\"

    stSQL = "SELECT Ship.Ship FROM Ship WHERE (((Ship.ID)<> 26 and (Ship.ID)<> 27)) ORDER BY Ship.Ship"

    Set rs = db.OpenRecordset(stSQL)

    Do While Not rs.EOF
        ' Need to convert any spaces in ship name to _ for website
        stParam = LCase(Replace(rs!Ship, " ", "_"))
        stLinkCriteria = "[Ship] = '" & rs!Ship & "'"

        DoCmd.OpenReport stRptName, acViewPreview, , stLinkCriteria
        DoCmd.OutputTo acOutputReport, stRptName, acFormatPDF, stFTPpath & stParam & ".pdf", False
        DoCmd.Close acReport, stRptName

        rs.MoveNext

    Loop
    rs.Close
End Sub

HTH
 

Users who are viewing this thread

Top Bottom