Why would you place a sample on the web that asks for two variables which
are due to errors in the report. There is no TotalSort field in your
report's record source. It should be SumOfTotalSort.
Your text30 control source should be:
=1
I can't imagine why your primary grouping and sorting would be on a sum from
the record source "SumOfTotalSort". What field do you really want to group
by?
You have Tool Number as a column heading but no field to match.
This code in your form causes a blank msgbox since your code runs right into
the error handling. There should be an Exit prior to the error handling.
Also, I don't think there is any reason to open the report since it is
already being opened.
Private Sub cmdDateSumQuery_Click()
On Error GoTo Err_cmdDateSumQuery_Click
Me.Visible = False
Dim stDocName As String
'stDocName = "rptDateRangeSums"
'DoCmd.OpenReport stDocName, acViewPreview
Err_cmdDateSumQuery_Click:
MsgBox Err.Description
'Resume Exit_cmdDateSumQuery_Click
End Sub
Did you try this query as a starting point for your report:
SELECT Date, [Part Number], SortTime, TotalSort,
NCM_Num, Containment, PlantNum,
Val(Nz((Select Sum(DefQuantity)
FROM tblDefects
WHERE tblDefects.ID = [tbl Defect Count].ID),0)) AS Defects
FROM [TBL defect count];