Export macro woes (1 Viewer)

ethan.geerdes

Registered User.
Local time
Yesterday, 22:46
Joined
Jun 4, 2015
Messages
116
I almost have my project complete but I need to export a table. I was able to do it the way it needed to be through the export wizard so I think there is a way to specify this in code so that I can tie this to a button but need some help. In the wizard, I select the export to text feature. Select my destination, leave the "export data with formatting and layout" unchecked, choose a delimited export, I use the | as the field delimiter and the text qualifier as a ^.



In the macros I found the ImportExport to Text but I couldn't figure out how to work that to get what I needed.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:46
Joined
Oct 29, 2018
Messages
21,358
Hi Ethan. When you used the Wizard, did you tell Access to save the Export steps when it asked you at the end? Just curious...
 

ethan.geerdes

Registered User.
Local time
Yesterday, 22:46
Joined
Jun 4, 2015
Messages
116
no I didn't.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:46
Joined
Oct 29, 2018
Messages
21,358
no I didn't.
Okay. Just curious; because if you did, you can simply try to rerun it using a macro. However, there are other ways of exporting a table using a macro like the ExportWithFormatting action. If you had saved the steps from the wizard, you could also use the RunSavedImportExport action. And if you decide to use VBA, there's even more choices for you to export the table.
 

ethan.geerdes

Registered User.
Local time
Yesterday, 22:46
Joined
Jun 4, 2015
Messages
116
Ok, I just went through and saved it. how do I do the macro so run the saved template?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:46
Joined
Oct 29, 2018
Messages
21,358
Ok, I just went through and saved it. how do I do the macro so run the saved template?
Hi. In case you missed it, I mentioned it above. Try using the RunSavedImportExport action. Hope it helps...
 

ethan.geerdes

Registered User.
Local time
Yesterday, 22:46
Joined
Jun 4, 2015
Messages
116
Thank you. I found it. My brain read that with spaces so it missed it in the first look. one more question, is there a way to have a variable in the form be in the file name of the document? I'm thinking like a date range.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:46
Joined
Oct 29, 2018
Messages
21,358
Thank you. I found it. My brain read that with spaces so it missed it in the first look. one more question, is there a way to have a variable in the form be in the file name of the document? I'm thinking like a date range.
Now, you're getting into the limitations with macros. This won't be possible with just a macro using the saved export task. But if you use VBA, then you can do almost anything.
 

zeroaccess

Active member
Local time
Today, 00:46
Joined
Jan 30, 2020
Messages
671
Export from a query based on the table instead of the table directly.

In the query builder, for the Criteria for your Date, put:

BETWEEN [Start Date] AND [End Date]

You would be prompted to enter the dates when exporting.

Even better is to make a form with a button that invokes this macro with unbound Start Date and End Date text boxes on the form. The Start Date and End Date in the query criteria would be the references to those text boxes. Set the text boxes to have a date picker and you're all set.
 

Users who are viewing this thread

Top Bottom