i have a form with checkbox, combobox and 2 textboxes. i am trying to export my query results based on the form's control into excel. here is my code
im frm As Form, ctl As Control
Dim varItm As Variant
Dim strList As String
Dim rs As Recordset
Dim qdf As QueryDef
Dim sql As String
Dim filename As String
filename = GetSaveFile
If Len(filename) < 5 Then
Exit Sub
Else
If Me.ChkAll = True Then
sql = "select * from QuarterlyDup"
ElseIf Not IsNull(qrt) Then
sql = "select * from QuarterlyDup WHERE ((([QuarterlyDup].[quarter])= '" & Me.cmbQrt.Value & "'));"
Else
sql = " select * from QuarterlyDup where (THgAnalyticalRuns.AnalysisDate) Between " & Me.SDate.Value & " And " & Me.Edate.Value
End If
Set rs = CurrentDb.OpenRecordset(sql, dbOpenDynaset)
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, rs, filename
End If
Let me know what i missing here,
Thanks in advance
im frm As Form, ctl As Control
Dim varItm As Variant
Dim strList As String
Dim rs As Recordset
Dim qdf As QueryDef
Dim sql As String
Dim filename As String
filename = GetSaveFile
If Len(filename) < 5 Then
Exit Sub
Else
If Me.ChkAll = True Then
sql = "select * from QuarterlyDup"
ElseIf Not IsNull(qrt) Then
sql = "select * from QuarterlyDup WHERE ((([QuarterlyDup].[quarter])= '" & Me.cmbQrt.Value & "'));"
Else
sql = " select * from QuarterlyDup where (THgAnalyticalRuns.AnalysisDate) Between " & Me.SDate.Value & " And " & Me.Edate.Value
End If
Set rs = CurrentDb.OpenRecordset(sql, dbOpenDynaset)
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, rs, filename
End If
Let me know what i missing here,
Thanks in advance