given name to exported query

pacuar

New Member
Joined
Mar 25, 2017
Messages
2
Hello everyone! I want to export ms access qry to excel

In an MS Access Form have 3 txtboxes to export querys to Excel
txtboxd. User picks a day from ms access calendar as dd/mm/yyyy
txtboxw. User enters week number as ww, yyyy
txtboxm. User enters month, year (mmm, year)


If user picks in textboxd 23_03_2017 I have a cmb with code to export query to Excel.
However, exported query name is Me.txtcos_dy _qcos_dy but,
I need such file name as the date user picks, for example 23_03_2017_qcos_dy.
I have been googling and testing many ways with no success.


Please, could you help me with that? Thx a lot!


Private Sub cmb_cos_dy_Click()Dim filename1 As String
Dim filename2 As String

If DCount("*", "qcos_dy") <> 0 Then
filename1 = "D:\Me.txtcos_dy " & "_" & "qcos_dy" & ".xlsx"


Debug.Print filename2
DoCmd.OutputTo acOutputQuery, "qcos_dy", acFormatXLSX, filename1, False

MsgBox "Query already exported to Excel"


Else
MsgBox "This day has no records"
DoCmd.Close acQuery, "qcos_dy"
End If
End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Not certain I understand the goal, but maybe

filename1 = "D:\" & Me.txtcos_dy " & "_" & "qcos_dy" & ".xlsx"
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,780
Messages
6,121,522
Members
449,037
Latest member
tmmotairi

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