help exporting from access using vba

bigmac1

New Member
Joined
Oct 9, 2016
Messages
17
hello all, can you help a newbie please , I have a access database , the main form has a subform, I am trying to get on the click of a button the subform to be saved as an excel worksheet I know I can do this through a macro but what I am trying to achieve is this.
on the mainform I have a text box I wold like to save the excel workbook under the name of the value in the textbox .
example the text box is called drawing,and contains the value "one" (value can change), so when I save the subform as a worksheet it will be called "drawing one". is this possible ? if so what is the vba code to do this please.
thanks in advance
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
In general no you do not save subforms as Excel worksheets.

*IF* the subform is a datasheet then you possibly can save the underlying query source for the subsheet as an Excel sheet. Calling it "drawing" may not work since once you save it, you cannot save it again without overwriting the first one. So you'd need to involve logic to detect and remove existing files as well.

Personally I'd recommend not thinking in terms of the subform but in terms of the criteria that creates the data in the subform. You can just query for the same data and send it to a worksheet using the transferspreadsheet function. But once again, *IF* the data in the subform is in datasheet form, you can potentially just click a button to export it (this method may be tricky or even not work at all since the description is for a form, not a subform):
https://support.office.com/en-us/article/Export-data-to-Excel-64E974E6-AE43-4301-A53E-20463655B1A9
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,558
Latest member
aivin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top