Save current records on form as pdf (1 Viewer)

Ameer

New member
Local time
Today, 13:20
Joined
Oct 1, 2020
Messages
7
So I have been making this database for a Small online business. And I’m having trouble exporting the record on my invoice form. When I add a export button it exports all records ( all invoices I have saved), I want to export the invoice that’s selected. Is there any way on how I can save pdf of the record I’m on only.
 

Gasman

Enthusiastic Amateur
Local time
Today, 08:20
Joined
Sep 21, 2011
Messages
7,787
Yes, you specify that record as criteria.?

How are you 'exporting' ?
Please show the code.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 08:20
Joined
Jul 9, 2003
Messages
12,474
This might be a bit more complicated than you need at the moment, but I thought you might be interested in it as a possible solution for the future.

Generate Multiple Reports

 

Ameer

New member
Local time
Today, 13:20
Joined
Oct 1, 2020
Messages
7
Yes, you specify that record as criteria.?

How are you 'exporting' ?
Please show the code.
I’m just using macro Exportwithformating. It exports all the records( All invoices I have created and saved) in the form. But I would like to save and export the selected invoice which is differentiated according to an invoice number(auto number) given to each invoice. I would like to use a code that would help me save the current form selected as PDF format.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:20
Joined
Oct 29, 2018
Messages
14,191
I’m just using macro Exportwithformating. It exports all the records( All invoices I have created and saved) in the form. But I would like to save and export the selected invoice which is differentiated according to an invoice number(auto number) given to each invoice. I would like to use a code that would help me save the current form selected as PDF format.
Hi. Are you exporting the form or a report? Can you show us your macro?
 

arnelgp

error reading drive A:
Local time
Today, 16:20
Joined
May 7, 2009
Messages
11,576
add Macro on the Form's Current Event:
t1.jpg

now, create a Query that will use Tempvars!tvar_invoice as it's Criteria:
t2.jpg

on the click of the button use the Query as Object Name of your ExportWithFormatting Macro:
t3.jpg
 

Ameer

New member
Local time
Today, 13:20
Joined
Oct 1, 2020
Messages
7
Hi. Are you exporting the form or a report? Can you show us your macro?
I’m exporting the form. And trying to save current record as PDF format.

so I have removed the macro and trying a code

DoCmd.OutputTo acOutputForm, “Invoice”, _
acFormatPDF, “Invoice.PDF”, True
End sub

This one still exports all records in the form but I would like to filter the record I’m on and export it only.
 

arnelgp

error reading drive A:
Local time
Today, 16:20
Joined
May 7, 2009
Messages
11,576
that is what my instruction is all about.
it's about creating a Filtered Query.
 

Ameer

New member
Local time
Today, 13:20
Joined
Oct 1, 2020
Messages
7
that is what my instruction is all about.
it's about creating a Filtered Query.
Yes but it exports the record as In the table. I want the form to be exported. I want the form view.
Any possibilities to filter from a code before exporting macro runs?
 

June7

AWF VIP
Local time
Yesterday, 23:20
Joined
Mar 9, 2014
Messages
3,387
Apply filter criteria to form or build a report and apply filter to report when it opens and export report.
 

arnelgp

error reading drive A:
Local time
Today, 16:20
Joined
May 7, 2009
Messages
11,576
you mean the "Form" itself?
 

Ameer

New member
Local time
Today, 13:20
Joined
Oct 1, 2020
Messages
7
you mean the "Form" itself?
Yes. The form itself but the selected record only. For example I selected invoice# 1 and when I try to export it all other invoices also exports along with it. I want invoice #1 to be on the PDF only.
 

arnelgp

error reading drive A:
Local time
Today, 16:20
Joined
May 7, 2009
Messages
11,576
try post #11.

EDIT:
i can give you code to take a Snapshot (bmp or jpg) of the Form.
but you need Adobe Acrobat professional to convert the image to pdf.
 
Last edited:

Ameer

New member
Local time
Today, 13:20
Joined
Oct 1, 2020
Messages
7
try post #11.

EDIT:
i can give you code to take a Snapshot (bmp or jpg) of the Form.
but you need Adobe Acrobat professional to convert the image to pdf.
Yes please.
 

June7

AWF VIP
Local time
Yesterday, 23:20
Joined
Mar 9, 2014
Messages
3,387
Re: Post #11 - apply filter to form so it has only the one record for export.

So in some event have code like:

Me.Filter = "ID=" & Me.ID
Me.FilterOn = True

The real trick is figuring out what event to put code into.

Alternatively, which is probably simpler, is to build a report and apply filter to report when it opens. This is really quite basic Access functionality.
 

Users who are viewing this thread

Top Bottom