VBA Enhancement

nancybrown

Well-known Member
Joined
Apr 7, 2005
Messages
868
Hi,

I converted an Access macro to VBA, I have a cmd button (cmdDD) on my form (frmDateDescription) to export this to a specific location. Can someone tell me please how to modify the code below in my Event Procedure of the cmd button to point to K:\CLE09\keyfound\Trust - Check Print for the export location.

Thank you in advance.

Private Sub DateDescription_Click()

DoCmd.OutputTo acOutputQuery, "qryCheckDateDescription", "ExcelWorkbook(*.xlsx)", True, "", , acExportQualityPrint



End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
What's curious is the syntax of the code line. You seem to be missing the output format (which normally means you'd get a prompt for it), so I'm kind of surprised it would work because when you omit optional parameter values but follow the omission with another parameter value, the missing parameter must be delimited with commas (as in where you have ,,). Saying that because ExcelWorkbook doesn't seem like a permitted value for the output format. So here's a link to the syntax - https://msdn.microsoft.com/en-us/vba/access-vba/articles/docmd-outputto-method-access
Perhaps all you're missing is the path. At least that link ought to show you where to put it.
 
Upvote 0
Hi, what am I doing wrong . . . it's been a few years since working VBA . . . I keep getting a debug at the DoCmd line "run time 3170"


Private Sub cmdDD_Click()

Dim i As Integer
Dim myQueryName As String
Dim myExportFileName As String

myQueryName = "qryChecksbyDate" & Format(i, "00")
myExportFileName = "K:\CLE09\keyfound\Trust-Check Print" & Format(i, "00") & ".xlsx"

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel10, myQueryName, myExportFileName, True

End Sub
 
Upvote 0
I assume i will be zero since you never set it.
Is qryChecksbyDate00 the name of a query that exists in your database?
 
Upvote 0
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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