Forums
This topic is locked
searching for records that are NOT there?
Posted 21 Oct 2002 15:15:49
1
has voted
21 Oct 2002 15:15:49 Brian Dunk posted:
Hello there. I am createing a web application that allows are company to keep track of what employees have taken required OSHA training courses. One of the searches that are user dooes is search for courses that employees have NOT taken. Is it possible to search my Access db records for values that are NOT there? thanks in advance for the info.Brian
Replies
Replied 22 Oct 2002 17:16:09
22 Oct 2002 17:16:09 Ken Blasdel replied:
You can use SQL, I have one that searches a database for information but had to make sure it got 'null' entries also (it was filtering them out since they had no data in them). It looked something like this
<pre id=code><font face=courier size=2 id=code> <%
Dim Recordset2
Dim Recordset2_numRows
Set Recordset2 = Server.CreateObject("ADODB.Recordset"
Recordset2.ActiveConnection = MM_conDist5_STRING
Recordset2.Source = "SELECT * FROM Dist5 WHERE (index_number LIKE '%" + Replace(Recordset2__varIndexNum, "'", "''" + "%' OR Index_number IS NULL) AND (PID_No LIKE '%" + Replace(Recordset2__varPIDNum, "'", "''" + "%' OR PID_No IS NULL) AND (County LIKE '%" + Replace(Recordset2__varCounty, "'", "''" + "%' OR County IS NULL) AND (plan_year LIKE '%" + Replace(Recordset2__varPlanYear, "'", "''" + "%' OR plan_year IS NULL) AND (route LIKE '%" + Replace(Recordset2__varStateRoute, "'", "''" + "%' OR route IS NULL) AND (city_village LIKE '%" + Replace(Recordset2__varVillage, "'", "''" + "%' OR city_village IS NULL) AND (township LIKE '%" + Replace(Recordset2__varTownship, "'", "''" + "%' OR township IS NULL) AND (Quarter_TWP LIKE '%" + Replace(Recordset2__varQuartTown, "'", "''" + "%' OR Quarter_TWP IS NULL) AND (section LIKE '%" + Replace(Recordset2__varSection, "'", "''" + "%' OR section IS NULL) AND (Platbook_page LIKE '%" + Replace(Recordset2__varPlatBP, "'", "''" + "%' OR platbook_page IS NULL) ORDER BY " + Replace(Recordset2__MM_sort, "'", "''" + " " + Replace(Recordset2__MM_order, "'", "''" + ""
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()
Recordset2_numRows = 0
%>
</font id=code></pre id=code>
If i just wanted to search for null items in one spot it might look like this..
<pre id=code><font face=courier size=2 id=code> <%
Dim Recordset2
Dim Recordset2_numRows
Set Recordset2 = Server.CreateObject("ADODB.Recordset"
Recordset2.ActiveConnection = MM_conDist5_STRING
Recordset2.Source = "SELECT * FROM Dist5 WHERE County IS NULL)
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()
Recordset2_numRows = 0
%>
</font id=code></pre id=code>
hope that helps
<pre id=code><font face=courier size=2 id=code> <%
Dim Recordset2
Dim Recordset2_numRows
Set Recordset2 = Server.CreateObject("ADODB.Recordset"
Recordset2.ActiveConnection = MM_conDist5_STRING
Recordset2.Source = "SELECT * FROM Dist5 WHERE (index_number LIKE '%" + Replace(Recordset2__varIndexNum, "'", "''" + "%' OR Index_number IS NULL) AND (PID_No LIKE '%" + Replace(Recordset2__varPIDNum, "'", "''" + "%' OR PID_No IS NULL) AND (County LIKE '%" + Replace(Recordset2__varCounty, "'", "''" + "%' OR County IS NULL) AND (plan_year LIKE '%" + Replace(Recordset2__varPlanYear, "'", "''" + "%' OR plan_year IS NULL) AND (route LIKE '%" + Replace(Recordset2__varStateRoute, "'", "''" + "%' OR route IS NULL) AND (city_village LIKE '%" + Replace(Recordset2__varVillage, "'", "''" + "%' OR city_village IS NULL) AND (township LIKE '%" + Replace(Recordset2__varTownship, "'", "''" + "%' OR township IS NULL) AND (Quarter_TWP LIKE '%" + Replace(Recordset2__varQuartTown, "'", "''" + "%' OR Quarter_TWP IS NULL) AND (section LIKE '%" + Replace(Recordset2__varSection, "'", "''" + "%' OR section IS NULL) AND (Platbook_page LIKE '%" + Replace(Recordset2__varPlatBP, "'", "''" + "%' OR platbook_page IS NULL) ORDER BY " + Replace(Recordset2__MM_sort, "'", "''" + " " + Replace(Recordset2__MM_order, "'", "''" + ""
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()
Recordset2_numRows = 0
%>
</font id=code></pre id=code>
If i just wanted to search for null items in one spot it might look like this..
<pre id=code><font face=courier size=2 id=code> <%
Dim Recordset2
Dim Recordset2_numRows
Set Recordset2 = Server.CreateObject("ADODB.Recordset"
Recordset2.ActiveConnection = MM_conDist5_STRING
Recordset2.Source = "SELECT * FROM Dist5 WHERE County IS NULL)
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()
Recordset2_numRows = 0
%>
</font id=code></pre id=code>
hope that helps