D
dohernan
I changed a Query and the Form that used to work went blank.
I've tried doing a new form, renaming everything, running Wizards etc.
I want the person to be prompted for 2 dates, they correlate to the
"Completed" date field in a Table that's tied to the Query that this form is
based on
The form consists of 2 text boxes one is a Start Query Date, the other End
Query Date, and 1 command button to Preview the Report.
The text boxes have Defaults values- =IIf(Time()<0.5,Date()-1,Date())-6
=IIf(Time()<0.5,Date()-1,Date())
The Button-
++++++
Option Compare Database
Private Sub HowManyofEachFormCompleted_Click()
On Error GoTo Err_HowManyofEachFormCompleted_Click
Dim stDocName As String
DoCmd.OpenReport
Dim strWhere As String
strWhere = "1=1 "
If Not IsNull(Me.StartQueryDate) Then
strWhere = strWhere & " AND Completed >=#" & _
Me.StartQueryDate & "# "
End If
If Not IsNull(Me.EndQueryDate) Then
strWhere = strWhere & " AND Completed <=#" & _
Me.EndQueryDate & "# "
Dim strWhere As String
strWhere = " 1=1 "
If Not IsNull(Me.StartQueryDate) Then
strWhere = strWhere & " AND Completed >=#" & _
Me.StartQueryDate & "# "
End If
If Not IsNull(Me.EndQueryDate) Then
strWhere = strWhere & " AND Completed <=#" & _
Me.EndQueryDate & "# "
End If
stDocName = "HowManyofEachFormCompleted"
DoCmd.OpenReport stDocName, acPreview, , strWhere
Exit_StatReportbyDatesForm_Click:
Exit Sub
Err_StatReportbyDatesForm_Click:
MsgBox Err.Description
Resume Exit_StatReportbyDates_Click
End Sub
Private Sub OpeningReport_Click()
End Sub
Private Sub PreviewButton_Click()
On Error GoTo Err_PreviewButton_Click
Dim stDocName As String
stDocName = "HowManyofEachFormCompleted"
DoCmd.OpenReport stDocName, acPreview
Exit_PreviewButton_Click:
Exit Sub
Err_PreviewButton_Click:
MsgBox Err.Description
Resume Exit_PreviewButton_Click
End Sub
++++++
The Query SQL -
SELECT PersonnelForms2009.[Form Type],
Count(PersonnelForms2009.[Form Type]) AS QTY
FROM PersonnelForms2009
WHERE [Completed] Between Forms!StatReportByDatesForm!StartQueryDate
And
Forms!StatReportByDatesForm!EndQueryDate
GROUP BY PersonnelForms2009.[Form Type]
UNION ALL SELECT tblOtherForms.[Form Type], Sum(Qty)
FROM tblOtherForms
WHERE [Completed] Between Forms!StatReportByDatesForm!StartQueryDate
And
Forms!StatReportByDatesForm!EndQueryDate
GROUP BY tblOtherForms.[Form Type];
Thanks!
I've tried doing a new form, renaming everything, running Wizards etc.
I want the person to be prompted for 2 dates, they correlate to the
"Completed" date field in a Table that's tied to the Query that this form is
based on
The form consists of 2 text boxes one is a Start Query Date, the other End
Query Date, and 1 command button to Preview the Report.
The text boxes have Defaults values- =IIf(Time()<0.5,Date()-1,Date())-6
=IIf(Time()<0.5,Date()-1,Date())
The Button-
++++++
Option Compare Database
Private Sub HowManyofEachFormCompleted_Click()
On Error GoTo Err_HowManyofEachFormCompleted_Click
Dim stDocName As String
DoCmd.OpenReport
Dim strWhere As String
strWhere = "1=1 "
If Not IsNull(Me.StartQueryDate) Then
strWhere = strWhere & " AND Completed >=#" & _
Me.StartQueryDate & "# "
End If
If Not IsNull(Me.EndQueryDate) Then
strWhere = strWhere & " AND Completed <=#" & _
Me.EndQueryDate & "# "
Dim strWhere As String
strWhere = " 1=1 "
If Not IsNull(Me.StartQueryDate) Then
strWhere = strWhere & " AND Completed >=#" & _
Me.StartQueryDate & "# "
End If
If Not IsNull(Me.EndQueryDate) Then
strWhere = strWhere & " AND Completed <=#" & _
Me.EndQueryDate & "# "
End If
stDocName = "HowManyofEachFormCompleted"
DoCmd.OpenReport stDocName, acPreview, , strWhere
Exit_StatReportbyDatesForm_Click:
Exit Sub
Err_StatReportbyDatesForm_Click:
MsgBox Err.Description
Resume Exit_StatReportbyDates_Click
End Sub
Private Sub OpeningReport_Click()
End Sub
Private Sub PreviewButton_Click()
On Error GoTo Err_PreviewButton_Click
Dim stDocName As String
stDocName = "HowManyofEachFormCompleted"
DoCmd.OpenReport stDocName, acPreview
Exit_PreviewButton_Click:
Exit Sub
Err_PreviewButton_Click:
MsgBox Err.Description
Resume Exit_PreviewButton_Click
End Sub
++++++
The Query SQL -
SELECT PersonnelForms2009.[Form Type],
Count(PersonnelForms2009.[Form Type]) AS QTY
FROM PersonnelForms2009
WHERE [Completed] Between Forms!StatReportByDatesForm!StartQueryDate
And
Forms!StatReportByDatesForm!EndQueryDate
GROUP BY PersonnelForms2009.[Form Type]
UNION ALL SELECT tblOtherForms.[Form Type], Sum(Qty)
FROM tblOtherForms
WHERE [Completed] Between Forms!StatReportByDatesForm!StartQueryDate
And
Forms!StatReportByDatesForm!EndQueryDate
GROUP BY tblOtherForms.[Form Type];
Thanks!