button in form to export a table data in pdf and excel format (1 Viewer)

akika

Registered User.
Local time
Today, 04:31
Joined
Aug 7, 2018
Messages
102
hi,
in access 2016, In a form, i have a buttons
'Generate pdf'
'Generate excel'

How can configure these 2 butons that when click on 'generate pdf'
it create specific column in table Customer
first_name, last_name, address, phone, mobile
into PDF in a specfic folder
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:31
Joined
Oct 29, 2018
Messages
21,510
Hi. Check out the OutpuTo method.

Sent from phone...
 

akika

Registered User.
Local time
Today, 04:31
Joined
Aug 7, 2018
Messages
102
Thxs.
ive used
DoCmd.OutputTo acOutputTable, "client", _
acFormatPDF, "client.pdf", True

how can i put specific fields from that table to be export in the pdf and to add a timestamp with that client.pdf
?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 04:31
Joined
Aug 30, 2003
Messages
36,129
Create a query that returns the desired fields and output that instead of the table.
 

akika

Registered User.
Local time
Today, 04:31
Joined
Aug 7, 2018
Messages
102
its ok when i ve used the query.

Ive added more coding in attach DB, getting error in invalid path even if path exists
can u pls check wht i did wrong?
and how to add a timestamp and move existing file to a backup folder?
 

Attachments

  • Database9.zip
    46.5 KB · Views: 46

pbaldy

Wino Moderator
Staff member
Local time
Today, 04:31
Joined
Aug 30, 2003
Messages
36,129
The problem isn't the path, it's the name (Me.Name is the name of the form). This works:

DoCmd.OutputTo acOutputQuery, "client query", acFormatPDF, filePath

Not clear what you want for a timestamp, but perhaps this type of thing?

filePath = fldrPath & "" & fileName & Format(Date(), "yyyymmdd") & ".pdf"

You can use FileCopy to copy a file.
 

Users who are viewing this thread

Top Bottom