I need to do a weekly report that need to include date ranges, make user select a piece of data from a field or basically sort the report by HARV, and do a calculation using a variable. I have done the date ranges before so they work, I chose a combo box to ask the user for certian data from a field (HARV), but it is not sorting correctly. Lastly I need the user to enter a variable number and do a calculation and have it reported. This is what I have so far on my command button:
Private Sub Command0_Click()
Dim strReport As String 'Name of report to open.
Dim strField As String 'Name of your date field.
Dim strWhere As String 'Where condition for OpenReport.
Const conDateFormat = "\#mm\/dd\/yyyy\#"
strReport = "Contractor's Weekly Summary Report"
strField = "DATE"
If IsNull(Me.txtStartDate) Then
If Not IsNull(Me.txtEndDate) Then 'End date, but no start.
strWhere = strField & " < " & Format(Me.txtEndDate, conDateFormat)
End If
Else
If IsNull(Me.txtEndDate) Then 'Start date, but no End.
strWhere = strField & " > " & Format(Me.txtStartDate, conDateFormat)
Else 'Both start and end dates.
strWhere = strField & " Between " & Format(Me.txtStartDate, conDateFormat) _
& " And " & Format(Me.txtEndDate, conDateFormat)
End If
End If
' Debug.Print strWhere 'For debugging purposes only.
DoCmd.OpenReport strReport, acViewPreview, , strWhere
Me.Visible = False
End Sub
Private Sub Command1_Click()
DoCmd.Close acForm, Me.Name
End Sub
Once the user enters the variable number I am trying to save it in CHAPPX within a query and do the calculations and then get it to the report labeled "Contractor's Weekly Summary Report".
Thanks
Private Sub Command0_Click()
Dim strReport As String 'Name of report to open.
Dim strField As String 'Name of your date field.
Dim strWhere As String 'Where condition for OpenReport.
Const conDateFormat = "\#mm\/dd\/yyyy\#"
strReport = "Contractor's Weekly Summary Report"
strField = "DATE"
If IsNull(Me.txtStartDate) Then
If Not IsNull(Me.txtEndDate) Then 'End date, but no start.
strWhere = strField & " < " & Format(Me.txtEndDate, conDateFormat)
End If
Else
If IsNull(Me.txtEndDate) Then 'Start date, but no End.
strWhere = strField & " > " & Format(Me.txtStartDate, conDateFormat)
Else 'Both start and end dates.
strWhere = strField & " Between " & Format(Me.txtStartDate, conDateFormat) _
& " And " & Format(Me.txtEndDate, conDateFormat)
End If
End If
' Debug.Print strWhere 'For debugging purposes only.
DoCmd.OpenReport strReport, acViewPreview, , strWhere
Me.Visible = False
End Sub
Private Sub Command1_Click()
DoCmd.Close acForm, Me.Name
End Sub
Once the user enters the variable number I am trying to save it in CHAPPX within a query and do the calculations and then get it to the report labeled "Contractor's Weekly Summary Report".
Thanks