In an MS Access Form I 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 _queryname. But,
I need such file name as the date user picks, for example: 23_03_2017_queryname.
I have been googling and testing many ways with no success.:banghead:
Please, could you help me with that? Thx a lot!
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 _queryname. But,
I need such file name as the date user picks, for example: 23_03_2017_queryname.
I have been googling and testing many ways with no success.:banghead:
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("*", "queryname") <> 0 Then
filename1 = "D:\Me.txtd " & "_" & "queryname" & ".xlsx"
Debug.Print filename2
DoCmd.OutputTo acOutputQuery, "queryname", acFormatXLSX, filename1, False
MsgBox "Query already exported to Excel"
Else
MsgBox "This day has no records"
DoCmd.Close acQuery, "queryname"
End If
End Sub