Good Morning. I am sure that I am doing something wrong here, or I have not been clear about what I am trying to accomplish. I realize that I have omitted something that might be very important. I am trying to use this SQL statement as the filter on a report. The complete sub is:
Code:
Private Sub cmdGo1_Click() ' Contract Report - Invoicing
Dim CountProc As Integer
Dim strRptSQL1 As String
Dim strRptSQL2 As String
dt1 = Me.tbxDate1
dt2 = Me.tbxDate2
strRptSQL1 = "SELECT * FROM WOTracking WHERE ContractCo = '" & Me.cbxContractCo & "' AND Date_Time >= #" & Format(dt1, "yyyy-mm-dd") & "# AND Date_Time < #" & Format(dt2, "yyyy-mm-dd") & "#;"
DoCmd.OpenReport "ContInvoice", acViewPreview, strRptSQL1
strRptSQL2 = "SELECT DISTINCT Process, Count(*) AS CountProc FROM WOTracking WHERE Date_Time BETWEEN #" & Format(dt1, "yyyy-mm-dd") & "# AND #" & Format(dt2, "yyyy-mm-dd") & "# GROUP BY Process;"
DoCmd.OpenReport "ProcessInvoiceSub", acViewPreview, strRptSQL2
End Sub
It is generating both reports. The second one with the Process counts just creating a list of all of the processes between the dates (no counts). So this leads me to 2 questions. How to get each process listed just once with the count next to it? And how to pass the CountProc for each Process to the report?