Copy a form data in report with button click (1 Viewer)

hrdpgajjar

Registered User.
Local time
Today, 07:57
Joined
Sep 24, 2019
Messages
76
Hi all,
I am trying to generate a payment slip (designed report) from an opened form.

I have a form named "payment details" It has following details opened,
Note : all data is for example

1. Payment No :123
2.Party Name : ABC
3.UTR Number : XCH34809


Now I need to create a slip design (report design) using above three details. I have created a button named "generate payment slip" so when i click on this button, my slip design (report) auto fill the three details. Like Payment No :123, party name : ABC and UTR Number : XCH34809.


So how to pull the details from opened form to my report?

How can i do this?


Thanks
 
Like this, which is someone elses DB with criteria for their report.
1732197775341.png


And the sql is
Code:
SELECT communicationst.organisationname,
       commsdatat.selected,
       commsdatalistt.listitem,
       commsdatat.timespent,
       regiont.region,
       constituencyt.constituency,
       localauthorityt.localauthority,
       organisationdetailst.organisationurn,
       countryt.country,
       communicationst.contactdate,
       organisationdetailst.nonmember
FROM   ((countryt
         INNER JOIN (localauthorityt
                     INNER JOIN (constituencyt
                                 INNER JOIN regiont
                                         ON constituencyt.regionid =
                                            regiont.regionid)
                             ON localauthorityt.regionid = regiont.regionid)
                 ON countryt.countryid = localauthorityt.countryid)
        INNER JOIN organisationdetailst
                ON ( regiont.regionid = organisationdetailst.regionid )
                   AND ( localauthorityt.localauthorityid =
                         organisationdetailst.localauthorityid )
                   AND ( countryt.countryid = organisationdetailst.countryid )
                   AND ( constituencyt.constituencyid =
                         organisationdetailst.constituencyid ))
       INNER JOIN (commsdatalistt
                   INNER JOIN (communicationst
                               INNER JOIN commsdatat
                                       ON communicationst.commsid =
                                          commsdatat.datalinkid)
                           ON commsdatalistt.listid = commsdatat.dataitems)
               ON organisationdetailst.organisationurn =
                  communicationst.organisationurn
WHERE  ( ( ( commsdatat.selected ) = true )
         AND ( ( communicationst.contactdate ) BETWEEN
               [forms] ! [reportslistf] ! [rstartdate]
                   AND
                   [forms] ! [reportslistf] ! [renddate] )
         AND ( ( organisationdetailst.nonmember ) = false )
         AND ( ( Iif(Isnull([forms] ! [reportslistf] ! [supporttxt]),
                 [listitem] LIKE "*"
                 ,
                         [listitem] = [forms] ! [reportslistf] ! [supporttxt]) )
               <>
               false
             )
         AND ( ( Iif(Isnull([forms] ! [reportslistf] ! [regiontxt]), [region]
                 LIKE "*",
                       [region]
                         = [forms] ! [reportslistf] ! [regiontxt]) ) <> false )
         AND ( ( Iif(Isnull([forms] ! [reportslistf] ! [consttxt]),
                 [constituency] LIKE "*",
                         [constituency] = [forms] ! [reportslistf] ! [consttxt])
               ) <>
               false )
         AND ( ( Iif(Isnull([forms] ! [reportslistf] ! [latxt]),
                 [localauthority] LIKE "*",
                         [localauthority] = [forms] ! [reportslistf] ! [latxt])
               ) <>
               false )
         AND ( ( Iif(Isnull([forms] ! [reportslistf] ! [countrytxt]),
                 [country] LIKE "*",
                         [country] = [forms] ! [reportslistf] ! [countrytxt]) )
               <>
               false
             ) );
 
Hi all,
I am trying to generate a payment slip (designed report) from an opened form.

I have a form named "payment details" It has following details opened,
Note : all data is for example

1. Payment No :123
2.Party Name : ABC
3.UTR Number : XCH34809


Now I need to create a slip design (report design) using above three details. I have created a button named "generate payment slip" so when i click on this button, my slip design (report) auto fill the three details. Like Payment No :123, party name : ABC and UTR Number : XCH34809.


So how to pull the details from opened form to my report?

How can i do this?


Thanks
I would typically use a report with a similar record source as the form and apply a WHERE condition in the DoCmd.OpenReport Method.

If your report has only those three data values, you can simply Add text boxes with control sources of
=Forms![YourFormName].[YourControlName]
 
From what you are describing, you are looking for a single piece of paper with only three items on it. I might create an unbound report containing ONLY those three fields in a Detail section with no headers or footers (unless you wanted a logo or something like that). Open this report from code in the original form. Once it is open, load the payment number, party name, and UTR number as fields. Then you could switch it to Print Preview and from there try a DoCmd.PrintOut acPrintAll on the operation. Then when the print has been started you can close that report without saving it.

The other possibility is if you have a report that can look at the same data source as the form you are using, you can build a report that has a filter in it and do an OpenReport with the filter turned on so that it only shows you the one record with payment, party, and UTR data. Then the same comments would apply as for the unbound form printout.
 
I'm going to guess that you don't really want an unbound report that takes three fields from the record displayed on a form but that you want a report that takes criteria. No code required. Just use the WHERE argument of the OpenReport Method. I'm also going to guess that Payment Number would be the ID that pulls this together. Your report may need to be bound to a query rather than a table to make this happen. The query would join the related tables and select all the data you want to see.
 

Users who are viewing this thread

Back
Top Bottom