Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Needed URGENTLY

Status
Not open for further replies.

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 & &quot;# AND INSPDATE <= #&quot; & endDate & &quot;#&quot;
End If
If Me.ckREINSP Then
dateReinspect = reinspectionDate
dateReinspectEnd = reinspectionDateEnd
reportSqlString = reportSqlString & &quot; AND REINSPDATE >= #&quot; & Me.reinspectionDate & &quot;#&quot; _
& &quot; AND REINSPDATE <= #&quot; & Me.reinspectionDateEnd & &quot;#&quot;
End If

If Me.ckDates Then
reportSqlString = reportSqlString & &quot; ORDER BY INSPDATE&quot;
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 & &quot; AND ptSystemID = &quot; & PRETREATMENTSYSTEM
End If
It keeps prompting me to enter parameter ptSystemID.
Please help!!!
thanks in advance
 
By asking you for a parameter, this means Access does not recognize that variable or field name. Ensure you have spelled it correctly, it is included as part of the record source, and that it is unique (if two or more tables have this same name, place the table name in front of it...[tablename]![ptSystemId]) If we knew what it was we were doing, it would not be called research, would it? - Albert Einstein [atom]

Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
check the column name - ptSystemID. Access is not recognizing the column name. Make sure its spelled correctly & exists.
 
Thanks guys!
You both are absolutely right!
Field name was not included in the query.
You guys are good!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top