Guest_imported
New member
- Jan 1, 1970
- 0
Public Function BUILD_QUERY_STRING()
On Error GoTo Err_BUILD_QUERY_STRING
reportSqlString = "SELECT * FROM " & reportQuery & " WHERE location = '" & strLocation & "' AND onLine = True"
If Me.ckFacilityName Then
reportSqlString = reportSqlString & " AND FACILITYNAME = " & """" & FACILITYNAME & """"
End If
If Me.ckZip Then
reportSqlString = reportSqlString & " AND ZIPCODE = '" & ZIPCODE & "'"
End If
If Me.ckFacilityType Then
reportSqlString = reportSqlString & " AND FACILITYTYPEID = " & facilityType
End If
If Me.ckArea Then
reportSqlString = reportSqlString & " AND areaID = " & AREA
End If
If Me.ckPTSystem Then
reportSqlString = reportSqlString & " AND ptSystemID = " & PRETREATMENTSYSTEM
End If
If Me.ckAddress Then
reportSqlString = reportSqlString & " AND ADDRESS = '" & Me.ADDRESS & "'"
End If
If Me.ckStatus Then
reportSqlString = reportSqlString & " AND statusID = " & STATUS
End If
If Me.ckStatus2 Then
reportSqlString = reportSqlString & " OR statusID = " & STATUS2
End If
If Me.ckTypeOfSystem Then
reportSqlString = reportSqlString & " AND systemID = " & TYPEOFSYSTEM
End If
If Me.ckDates Then
strDateStart = Me.startDate
strDateEnd = Me.endDate
reportSqlString = reportSqlString & " AND INSPDATE >= #" _
& startDate & "# AND INSPDATE <= #" & endDate & "#"
End If
If Me.ckREINSP Then
dateReinspect = reinspectionDate
dateReinspectEnd = reinspectionDateEnd
reportSqlString = reportSqlString & " AND REINSPDATE >= #" & Me.reinspectionDate & "#" _
& " AND REINSPDATE <= #" & Me.reinspectionDateEnd & "#"
End If
If Me.ckDates Then
reportSqlString = reportSqlString & " ORDER BY INSPDATE"
End If
Exit_BUILD_QUERY_STRING:
Exit Function
Err_BUILD_QUERY_STRING:
MsgBox Err.Description
Resume Exit_BUILD_QUERY_STRING
End Function
Everything works fine except this block of if statements:
If Me.ckPTSystem Then
reportSqlString = reportSqlString & " AND ptSystemID = " & PRETREATMENTSYSTEM
End If
It keeps prompting me to enter parameter.
Please help!!!
On Error GoTo Err_BUILD_QUERY_STRING
reportSqlString = "SELECT * FROM " & reportQuery & " WHERE location = '" & strLocation & "' AND onLine = True"
If Me.ckFacilityName Then
reportSqlString = reportSqlString & " AND FACILITYNAME = " & """" & FACILITYNAME & """"
End If
If Me.ckZip Then
reportSqlString = reportSqlString & " AND ZIPCODE = '" & ZIPCODE & "'"
End If
If Me.ckFacilityType Then
reportSqlString = reportSqlString & " AND FACILITYTYPEID = " & facilityType
End If
If Me.ckArea Then
reportSqlString = reportSqlString & " AND areaID = " & AREA
End If
If Me.ckPTSystem Then
reportSqlString = reportSqlString & " AND ptSystemID = " & PRETREATMENTSYSTEM
End If
If Me.ckAddress Then
reportSqlString = reportSqlString & " AND ADDRESS = '" & Me.ADDRESS & "'"
End If
If Me.ckStatus Then
reportSqlString = reportSqlString & " AND statusID = " & STATUS
End If
If Me.ckStatus2 Then
reportSqlString = reportSqlString & " OR statusID = " & STATUS2
End If
If Me.ckTypeOfSystem Then
reportSqlString = reportSqlString & " AND systemID = " & TYPEOFSYSTEM
End If
If Me.ckDates Then
strDateStart = Me.startDate
strDateEnd = Me.endDate
reportSqlString = reportSqlString & " AND INSPDATE >= #" _
& startDate & "# AND INSPDATE <= #" & endDate & "#"
End If
If Me.ckREINSP Then
dateReinspect = reinspectionDate
dateReinspectEnd = reinspectionDateEnd
reportSqlString = reportSqlString & " AND REINSPDATE >= #" & Me.reinspectionDate & "#" _
& " AND REINSPDATE <= #" & Me.reinspectionDateEnd & "#"
End If
If Me.ckDates Then
reportSqlString = reportSqlString & " ORDER BY INSPDATE"
End If
Exit_BUILD_QUERY_STRING:
Exit Function
Err_BUILD_QUERY_STRING:
MsgBox Err.Description
Resume Exit_BUILD_QUERY_STRING
End Function
Everything works fine except this block of if statements:
If Me.ckPTSystem Then
reportSqlString = reportSqlString & " AND ptSystemID = " & PRETREATMENTSYSTEM
End If
It keeps prompting me to enter parameter.
Please help!!!