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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering

Status
Not open for further replies.

1897

Programmer
Jan 28, 2002
8
GB
I've just started learning asp and i'm a bit confused.
I am designing a page that displays a current stock list. As soon as the pages open i would like it to display everthing that is in stock (in a table view)
Then at the top of the page it as an input box to enter a "StockCode" and a Button "btnfind.gif" that when pressed filters the records and just displays the StockCode input.

So far i've got it so when i open the page it
display everything in stock from an Access Database but i'm a bit confused on how to get the filter working when i enter the stockcode and press the Find Button.

Thanks
 
Have this code before you query your database...
Code:
<%
If Request.Form("stockcode") <> "" Then
  'Search performed so filter the recordset
  strSQL = "SELECT field1, field2 FROM myTable WHERE StockCode='" & Request.Form("stockcode") & "'"
Else
  'No search performed so show all records
  strSQL = "SELECT field1, field2 FROM myTable"
End If
%>

Tony
_______________________________________________________________
 
And of course the page should probably post to itself or better yet perhaps use get which puts all the fields into a querystring.

Classic ASP Design Tips - Post Back Page

Classic ASP Design Tips - QueryString


J. Paul Schmidt, Freelance ASP Web Developer
Classic ASP Design Tips, ASP Web Database Sample (Freely Downloadable)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top