Here is the complete string SQL
Public Function MyRptYear() As String
Dim SQLstr As String
SQLstr = "SELECT tblTPlant.TPlant AS TPlantID, "
SQLstr = SQLstr & "Sum(IIf([SConnTypeID]='NC
"And ((tblSewer.SanFlow<>0)),1,
"And DatePart('q',[permitedate]
"And DatePart('q',[permitedate]
"Sum(IIf([SConnTypeID]='PL
"([San FlowQ1]*0.65)-([Plug FlowQ1]*0.65) AS [Net FlowQ1], "
SQLstr = SQLstr & "Sum(IIf([SConnTypeID]='NC
"And ((tblSewer.SanFlow<>0)),1,
"And DatePart('q',[permitedate]
"And DatePart('q',[permitedate]
"Sum(IIf([SConnTypeID]='PL
"([San FlowQ2]*0.65)-([Plug FlowQ2]*0.65) AS [Net FlowQ2],"
SQLstr = SQLstr & "Sum(IIf([SConnTypeID]='NC
"And ((tblSewer.SanFlow<>0)),1,
"[SanFlow],0))AS [San FlowQ3], Sum(IIf([SConnTypeID]='PL'
"And ((tblSewer.PlugFlow<>0)),1
"AS [Plug FlowQ3], ([San FlowQ3]*0.65)-([Plug FlowQ3]*0.65) AS [Net FlowQ3],"
SQLstr = SQLstr & "Sum(IIf([SConnTypeID]='NC
"AS NCCountQ4, Sum(IIf([SConnTypeID]='NC'
"And DatePart('q',[permitedate]
"And DatePart('q',[permitedate]
SQLstr = SQLstr & "FROM tblTPlant INNER JOIN tblSewer ON tblTPlant.TPlantID = tblSewer.TPlantID "
SQLstr = SQLstr & "WHERE (((tblSewer.SewerTypeID) = 'SA' Or (tblSewer.SewerTypeID) = 'CM') " & _
"And ((DatePart('yyyy', [PermitEDate])) = " & [Forms]![Report Date Range]![input year] & ") And ((tblSewer.TPlantID) Is Not Null) " & _
"And ((tblSewer.PermitEDate) Is Not Null) And ((tblSewer.CIDate) Is Not Null) And ((tblSewer.PermitNo) Is Not Null)) "
SQLstr = SQLstr & "GROUP BY tblTPlant.TPlant; "
MyRptYear = SQLstr
Exit Function
End Function
' *********
Private Sub Report_Open(Cancel As Integer)
Me.RecordSource = MyRptYear()
End Sub
Main Topics
Browse All Topics





by: MikeToolePosted on 2006-09-10 at 04:41:24ID: 17489147
Hi,
It would be a good starting point if you posted the code that causes the Procedure too large error. There also apears to be a lot missing from the function you posted - it wouldn't compile as it is, and there doesn't seem a point in returning a SQL string as the result of the MyRptYear() function.