Hello,
I have been trying this for a while with no success. I was hoping for some assistance. I am going to sleep now, but will answer any followup questions in the morning.
I have a form with some controls to get criteria.
I am trying to complete the part of this process where a query I create in vba as a string with variable data gets exported to Excel.
The control values make up most of the query including which table to pull from.
Any help would be great. Thanks.
I have been trying this for a while with no success. I was hoping for some assistance. I am going to sleep now, but will answer any followup questions in the morning.
I have a form with some controls to get criteria.
I am trying to complete the part of this process where a query I create in vba as a string with variable data gets exported to Excel.
The control values make up most of the query including which table to pull from.
Any help would be great. Thanks.
Code:
Private Sub Command133_Click()
Dim Table_Name As String
Dim Table_Type As String
Dim strSQL As String
Select Case Me.Report_Type.Value
Case 1
Table_Type = "01 Month History"
Case 3
Table_Type = "03 Month History"
Case 6
Table_Type = "06 Month History"
Case 12
Table_Type = "12 Month History"
Case 2
Table_Type = "02 Month History"
Case 4
Table_Type = "Details"
Case 20
Table_Type = "Totals"
Case 47
Table_Type = "AA History"
Case 519
Table_Type = "BB History"
Case 1519
Table_Type = "CC History"
Case 1619
Table_Type = "DD History"
End Select
Table_Name = "Table" & Me.Report_Name_Toggle.Value & " " & Table_Type
strSQL = "SELECT * FROM [" & Table_Name & "] WHERE [Report Year] = '2015';"
'DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExce8, _
Qry, "C:\Users\Jaryd\Downloads\FileName.xls", True
'DoCmd.OutputTo acOutputQuery, strSQL, "ExcelWorkbook(*.xlsx)", "", False, "", , acExportQualityPrint
End Sub