I have two functinalities to capture.
One allows the user to search our db using the basic search option.
The other allows the user to search db using the advanced search option.
With the basic search option, you basically check a chekbox which disables the the advanced search option.
You then click the search button and all records in the db are displayed to the screen.
With the advanced search option, you search our db by specifying a search criterium to filter out unwanted columns.
The basic search feature appears to be working but the advanced search option is not working.
It is not working for two reasons:
One reason is because it is causing error:
Microsoft JET Database Engine (0x80040E10)
No value given for one or more required parameters.
I am not sure why it is giving this error because I used the bolean OR in my sql statements.
The other problem I am having is that when I first open the search form, all records are already displayed.
It should not be like that.
The search screen should be blank until an item is searched for.
I am dumping the code and I apologize for this dump as I don't believe I will make any sense without providing the codes.
Thanks y'all in advance
<html>
<head>
<body>
<%
' Constants ripped from adovbs.inc:
Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adCmdText = &H0001
' Our own constants:
Const PAGE_SIZE = 5 ' The size of our pages.
' Declare our variables... always good practice!
Dim strURL ' The URL of this page so the form will work
' no matter what this file is named.
Dim cnnSearch ' ADO connection
Dim rstSearch ' ADO recordset
Dim strDBPath ' path to our Access database (*.mdb) file
Dim strSQL ' The SQL Query we build on the fly
Dim strSearch ' The text being looked for
Dim iPageCurrent ' The page we're currently on
Dim iPageCount ' Number of pages of records
Dim iRecordCount ' Count of the records returned
Dim I ' Standard looping variable
' Retreive the URL of this page from Server Variables
strURL = Request.ServerVariables("URL")
page = Request.QueryString("page")
basicSearch = Request.QueryString("basicSearch")
selItemNo = Request.QueryString("selItemNo")
selDivision = Request.QueryString("selDivision")
selAnswer = Request.QueryString("selAnswer")
selKeyword = Request.QueryString("selKeyword")
btnAdd = Request.QueryString("btnAdd")
advanceSearch = Request.QueryString("advanceSearch")
' Retreive the term being searched for. I'm doing it on
' the QS since that allows people to bookmark results.
strSearch = Request.QueryString("search")
strSearch = Replace(strSearch, "'", "''")
' Retrieve page to show or default to the first
If page = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If
' Since I'm doing this all in one page I need to see if anyone
' has searched for something. If they have we hit the DB.
' O/W I just show the search form and quit.
%>
<%
'If strSearch <> "" Then
' Create an ADO Connection to connect to the sample database.
' We're using OLE DB but you could just as easily use ODBC or a DSN.
Set cnnSearch = Server.CreateObject("ADODB.Connection")
' We're actually using SQL Server so we use this line instead:
cnnSearch.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& server.MapPath("faqs.MDB")
' Build our query based on the input.
strSQL = "SELECT * FROM FAQ "
If advanceSearch = "ON" Then
strSQL = strSQL & " where Answer <> 'z' "
If selItemNo <> "" Then
strSQL = strSQL & " OR ItemNo = " & selItemNo & " "
End If
If selDivision <> "" Then
strSQL = strSQL & " OR Division LIKE '%" & selDivision & "%' "
End If
If selKeyword <> "" Then
strSQL = strSQL & " OR Question LIKE '%" & selKeyword & "%' "
End If
strSQL = strSQL & " "
End If
strSQL = strSQL & " ORDER BY Division DESC;"
' Execute our query using the connection object. It automatically
' creates and returns a recordset which we store in our variable.
Set rstSearch = Server.CreateObject("ADODB.Recordset")
rstSearch.PageSize = PAGE_SIZE
rstSearch.CacheSize = PAGE_SIZE
' Open our recordset
rstSearch.Open strSQL, cnnSearch, adOpenStatic, adLockReadOnly, adCmdText
' Get a count of the number of records and pages
' for use in building the header and footer text.
iRecordCount = rstSearch.RecordCount
iPageCount = rstSearch.PageCount
If iRecordCount = 0 Then
' Display no records error.
%>
<p>
No records found. Please try again.
</p>
<%
Else
' Move to the page we need to show.
rstSearch.AbsolutePage = iPageCurrent
' Show a quick status line letting people know where they are:
%>
<script language="javascript">
var Open = ""
var Closed = ""
function ProcessSearch(strcatvalue) {
strAction = "Faqss.asp"
document.forms[0].action=strAction
document.forms[0].submit()
}
function preload(){
if(document.images){
Open = new Image(12,6)
Closed = new Image(16,13)
Open.src = "arrow_open.gif"
Closed.src = "arrow.gif"
}
}
function showhide(what,what2){
if (what.style.display=='none'){
what.style.display='';
what2.src=Open.src
}
else{
what.style.display='none'
what2.src=Closed.src
}
}
</script>
<script language="javascript">
function call_forms() {
disval=(document.form1.forms.options[document.form1.forms.selectedIndex].value);
if(disval!="none")
{
window.location.href=disval;
&