I have a form that the user enters a financial quarter and year to produce a report. the report is based on a query that uses the quarter and year. seems simple enough. The financial quarter and year are drop down boxes. When the run query button is pushed the form concantinates the strings QueryStartDate and QueryEndDate. How do I refer to these variables in my query expression?
Public Sub Preview_Report_ Click()
On Error GoTo Err_Preview_Rep ort_Click
Dim stDocName As String
Dim QueryEndDate As String
Dim QueryStartDate As String
If Me.Quarter = 1 Then
QueryStartDate = "01/01/" & Me.Year
QueryEndDate = "04/01/" & Me.Year
ElseIf Me.Quarter = 2 Then
QueryStartDate = "04/01/" & Me.Year
QueryEndDate = "07/01/" & Me.Year
ElseIf Me.Quarter = 3 Then
QueryStartDate = "07/01/" & Me.Year
QueryEndDate = "09/01/" & Me.Year
ElseIf Me.Quarter = 4 Then
QueryStartDate = "09/01/" & Me.Year
QueryEndDate = "12/31/" & Me.Year
End If
stDocName = "QuarterlyTestR eport"
DoCmd.OpenRepor t stDocName, acPreview
Thanks in advance
PS if there is a simpler way to do this I would like to know.
Public Sub Preview_Report_ Click()
On Error GoTo Err_Preview_Rep ort_Click
Dim stDocName As String
Dim QueryEndDate As String
Dim QueryStartDate As String
If Me.Quarter = 1 Then
QueryStartDate = "01/01/" & Me.Year
QueryEndDate = "04/01/" & Me.Year
ElseIf Me.Quarter = 2 Then
QueryStartDate = "04/01/" & Me.Year
QueryEndDate = "07/01/" & Me.Year
ElseIf Me.Quarter = 3 Then
QueryStartDate = "07/01/" & Me.Year
QueryEndDate = "09/01/" & Me.Year
ElseIf Me.Quarter = 4 Then
QueryStartDate = "09/01/" & Me.Year
QueryEndDate = "12/31/" & Me.Year
End If
stDocName = "QuarterlyTestR eport"
DoCmd.OpenRepor t stDocName, acPreview
Thanks in advance
PS if there is a simpler way to do this I would like to know.
Comment