Here is the code that I have.
Expand|Select|Wrap|Line Numbers
- <html>
- <title>ECVS Report Generator</title>
- <head>
- <script>
- function clearForms()
- {
- var i;
- for (i = 0; (i < document.forms.length); i++) {
- document.forms[i].reset();
- }
- }
- </script>
- </head>
- <body bgcolor="#FFFFFF" onLoad="clearForms()" onUnload="clearForms()" background="http://bytes.com/images/background1.png">
- <%
- u_input1 = trim(request.form("u_input1"))
- u_input2 = trim(request.form("u_input2"))
- u_input3 = trim(request.form("u_input3"))
- u_field1=request.form("u_field1")
- u_field2=request.form("u_field2")
- u_field3=request.form("u_field3")
- if u_input1 <> "" then
- accessdb="custmast" '
- table_name="customermast"
- cn="driver={microsoft access driver (*.mdb)};"
- cn=cn & "dbq=" & server.mappath(accessdb)
- set rs = server.createobject("ADODB.Recordset")
- sql = "select * from "& table_name &" where " & u_field1 & " like '%%" & u_input1 & "%%' And " & u_field2 & " like '%%" & u_input2 & "%%' And " & u_field3 &" like '%%" & u_input3 & "%%' "
- rs.Open sql, cn
- if rs.eof or rs.bof then
- response.write "No results found..."
- observations=0
- else
- observations=1
- end if 'end check for observations
- end if 'end check for user input
- %>
- <%
- if observations > 0 then %>
- <!--- This is where it specifies what to do if there are observations ---->
- <table>
- <tr>
- <% 'Write the field names
- for each table_element in rs.fields
- %>
- <td><b><%= table_element.name%></B></TD><%
- next %>
- </tr>
- <tr>
- <% 'Write the values
- rs.movefirst
- do while not rs.eof
- for each cell in rs.fields %>
- <td><%= cell.value %></td><%
- next %>
- </tr>
- <% rs.movenext
- loop %>
- </table>
- <% end if 'end of check of obs for display%>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <table align="center">
- <tr>
- <td>
- <form action ="" method="post">
- <select name="u_field1" size="1">
- <option <% ' write out all the search fields and select
- if u_field1 = "state" or u_field1 = "" then
- response.write "selected "
- end if
- %>value="AccountNumber">Account Number</option>
- <option <%
- if u_field1 = "AccountName" then
- response.write "selected "
- end if
- %>value="AccountName">Account Name</option>
- <option <%
- if u_field1 = "SalesVolume" then
- response.write "selected "
- end if
- %>value="SalesVolume">Sales Volume</option>
- <option <%
- if u_field1 = "BusinessUnit" then
- response.write "selected "
- end if
- %>value="BusinessUnit">Business Unit</option><br>
- <option <%
- if u_field1 = "SalesRegion" then
- response.write "selected "
- end if
- %>value="SalesRegion">Sales Region</option>
- <option <%
- if u_field1 = "State" then
- response.write "selected "
- end if
- %>value="state">State</option>
- <option <%
- if u_field1 = "PriceGroup" then
- response.write "selected "
- end if
- %>value="PriceGroup">Price Group</option>
- <option <%
- if u_field1 = "DealerType" then
- response.write "selected "
- end if
- %>value="DealerType">Dealer Type</option>
- <option <%
- if u_field1 = "BillingType" then
- response.write "selected "
- end if
- %>value="BillingType">Address Type</option>
- <option <%
- if u_field1 = "StartDate" then
- response.write "selected "
- end if
- %>value="StartDate">Start Date</option>
- <option <%
- if u_field1 = "AccountRep" then
- response.write "selected "
- end if
- %>value="AccountRep">Account Rep</option>
- </select>
- =
- <input type="text" name="u_input1" value="<%= u_input1 %>">
- <br><br>
- AND
- <br><br>
- <select name="u_field2" size="1">
- <option <% ' write out all the search fields and select
- if u_field2 = "state" or u_field2 = "" then
- response.write "selected "
- end if
- %>value="AccountNumber">Account Number</option>
- <option <%
- if u_field2 = "AccountName" then
- response.write "selected "
- end if
- %>value="AccountName">Account Name</option>
- <option <%
- if u_field2 = "SalesVolume" then
- response.write "selected "
- end if
- %>value="SalesVolume">Sales Volume</option>
- <option <%
- if u_field2 = "BusinessUnit" then
- response.write "selected "
- end if
- %>value="BusinessUnit">Business Unit</option>
- <option <%
- if u_field2 = "SalesRegion" then
- response.write "selected "
- end if
- %>value="SalesRegion">Sales Region</option>
- <option <%
- if u_field2 = "State" then
- response.write "selected "
- end if
- %>value="state">State</option>
- <option <%
- if u_field2 = "PriceGroup" then
- response.write "selected "
- end if
- %>value="PriceGroup">Price Group</option>
- <option <%
- if u_field2 = "DealerType" then
- response.write "selected "
- end if
- %>value="DealerType">Dealer Type</option>
- <option <%
- if u_field2 = "BillingType" then
- response.write "selected "
- end if
- %>value="BillingType">Address Type</option>
- <option <%
- if u_field2 = "StartDate" then
- response.write "selected "
- end if
- %>value="StartDate">Start Date</option>
- <option <%
- if u_field2 = "AccountRep" then
- response.write "selected "
- end if
- %>value="AccountRep">Account Rep</option>
- </select>
- =
- <input type="text" name="u_input2" value="<%= u_input2 %>">
- <br><br>
- AND
- <br><br>
- <select name="u_field3" size="1">
- <option <% ' write out all the search fields and select
- if u_field3 = "state" or u_field3 = "" then
- response.write "selected "
- end if
- %>value="AccountNumber">Account Number</option>
- <option <%
- if u_field3 = "AccountName" then
- response.write "selected "
- end if
- %>value="AccountName">Account Name</option>
- <option <%
- if u_field3 = "SalesVolume" then
- response.write "selected "
- end if
- %>value="SalesVolume">Sales Volume</option>
- <option <%
- if u_field3 = "BusinessUnit" then
- response.write "selected "
- end if
- %>value="BusinessUnit">Business Unit</option>
- <option <%
- if u_field3 = "SalesRegion" then
- response.write "selected "
- end if
- %>value="SalesRegion">Sales Region</option>
- <option <%
- if u_field3 = "State" then
- response.write "selected "
- end if
- %>value="state">State</option>
- <option <%
- if u_field3 = "PriceGroup" then
- response.write "selected "
- end if
- %>value="PriceGroup">Price Group</option>
- <option <%
- if u_field3 = "DealerType" then
- response.write "selected "
- end if
- %>value="DealerType">Dealer Type</option>
- <option <%
- if u_field3 = "BillingType" then
- response.write "selected "
- end if
- %>value="BillingType">Address Type</option>
- <option <%
- if u_field3 = "StartDate" then
- response.write "selected "
- end if
- %>value="StartDate">Start Date</option>
- <option <%
- if u_field3 = "AccountRep" then
- response.write "selected "
- end if
- %>value="AccountRep">Account Rep</option>
- </select>
- =
- <input type="text" name="u_input3" value="<%= u_input3 %>">
- <br><br>
- &n bsp; &nbs p;
- &n bsp; &nbs p;
- &n bsp;
- <input type="submit" value="Submit">
- </form>
- </td>
- </tr>
- </table>
- <p> </p>