Howdy!
I can print preview my report using date criteria from a form (with user entry) but I don't see how I can do the same thing when I output to Excel. Can anyone suggest another method of action? (Feel free to criticize the way I coded this too - it works - but is not pretty!)
To Print Preview (this works)
Form has a frame (Frame) with 0 = all the data to be returned; -1 for the date selection based on the Microsoft Date and Time picker (From & To)
Sub Preview_Click()
If Me.Frame = 1 Then
' *** Handle date (from and to) entry / where clause ***
If Me.From.Value > Me.To.Value Then
MsgBox ("From date must be before To date")
Exit Sub
End If
Between = "date Between #" & Me.From & "# And #" & Me.To & "#"
DoCmd.OpenReport "Report", acPreview, , Between
Else
If Me.Frame = 0 Then
DoCmd.OpenReport "Report", acPreview
End If
End If
End Sub
To Export to Exccel (this needs help)
Form has the same frame (Frame) with 0 = all the data to be returned; -1 for the date selection based on the Microsoft Date and Time picker (From & To). This code does not include any date criteria from the form at all... please help me add it somehow!
Sub Export_Excel_Click()
DoCmd.OutputTo acOutputQuery, "Report_Query", acFormatXLS, "C:\Data\Report.xls"
End Sub
Suggestions?
Nowanda
I can print preview my report using date criteria from a form (with user entry) but I don't see how I can do the same thing when I output to Excel. Can anyone suggest another method of action? (Feel free to criticize the way I coded this too - it works - but is not pretty!)
To Print Preview (this works)
Form has a frame (Frame) with 0 = all the data to be returned; -1 for the date selection based on the Microsoft Date and Time picker (From & To)
Sub Preview_Click()
If Me.Frame = 1 Then
' *** Handle date (from and to) entry / where clause ***
If Me.From.Value > Me.To.Value Then
MsgBox ("From date must be before To date")
Exit Sub
End If
Between = "date Between #" & Me.From & "# And #" & Me.To & "#"
DoCmd.OpenReport "Report", acPreview, , Between
Else
If Me.Frame = 0 Then
DoCmd.OpenReport "Report", acPreview
End If
End If
End Sub
To Export to Exccel (this needs help)
Form has the same frame (Frame) with 0 = all the data to be returned; -1 for the date selection based on the Microsoft Date and Time picker (From & To). This code does not include any date criteria from the form at all... please help me add it somehow!
Sub Export_Excel_Click()
DoCmd.OutputTo acOutputQuery, "Report_Query", acFormatXLS, "C:\Data\Report.xls"
End Sub
Suggestions?
Nowanda