Esport an Excel File (1 Viewer)

madcats

Registered User.
Local time
Yesterday, 21:47
Joined
Jun 24, 2005
Messages
36
I am trying to use a macro using ExportWithFormatting to export a Table to an excel file.

I would like the file name to be a field in another table. This field is also in a form that is open if that is preferable.

There are many threads here and elsewhere and it seems this can't be accomplished using a macro.

I do not know how to use VB code, but if someone could help I might be able to get it done that way.

The name of the table to output is "BOM Table"

The name of the file I would like to use is a field named [Serial Number] in a table name [Selected Serial Number].

Any help would be appreciated.
 

Ranman256

Well-known member
Local time
Today, 00:47
Joined
Apr 9, 2015
Messages
4,339
In the form,have a box for the serial#,
The query will read this and put it in the query and the filename.
Instead of macro, use The export code :
Code:
Sub btnExport_click()
VFile= "c:\folder\" & txtSerial & ".xls"
Docmd.transferSpreadsheet acExport,  acSpreadsheetType12, "qsQuery", vFile, true, "TabName"
End sub
 

madcats

Registered User.
Local time
Yesterday, 21:47
Joined
Jun 24, 2005
Messages
36
Thank you for your reply. I have used Access many years and for many things but have always got by just using queries and macros. Probably what separates me from the experts.

I am sorry but I may need this help step by step. The code you sent me: do I need to paste this into an event procedure for "on click" in a command button?
 

madcats

Registered User.
Local time
Yesterday, 21:47
Joined
Jun 24, 2005
Messages
36
ranman,
Funny thing, I could not get this to work using a macro, but when I used the convert macro to visual basic I cut and pasted that code and it worked. Thanks for your help, I wouldn't have kept searching if it wasn't for your reply.
 

Users who are viewing this thread

Top Bottom