Do you mean when the user does not key in the 2 optional search criteria, u want to show all records cocerning dname="LB Smith" ?
If what I understand correctly,
first I need to know what database are u using? Is it just Access or MS SQL Server?
I'm not sure if Access SQL syantax supports "CASE ...WHEN..ELSE".
But MS SQL Server does. I'll give u a sample of how it can be done with only SQL Server syantax and how to go around it if u'r using Access.
Please note that I'm just writing on dry run, no testing of my code is done.
Code:
-- MS SQL Server Syantax
declare @attachserial as varchar(50),
@cname as varchar(50),
set @attachserial='"& Request.QueryString("keyword") &"'
set @cname='"&Request.QueryString("keyword")&"'
select * from warrantyclaims where dname = '("LB_Smith"))' and
case when @attachserial='' then '' else attachserial end like '%'+@attachserial+'%'
and case when @cname='' then '' else cname end like '%'+@cname+'%'
-- here, the syantax uses 'case' syantax to determine if the variable
-- is empty or not.
OR
Code:
-- If it is done via other DB like Access ( not sure if it supports the case --syantax anyway)
-- You assign your value to a ASP variable first and then do checking
-- and see if you need the additional "and statments for u'r SQL Syantax
Rough example
Dim AttachSerial,CName
AttachSerial=Request.QueryString("keyword")
CName=Request.QueryString("keyword")
SQL_Query="select * from warrantyclaims where dname = '("LB_Smith"))'"
if AttachSerial <>"" then
SQL_Query=SQL_Query + "and attachserial like "& AttachSerial &"
elseif CName <>"" then
SQL_Query=SQL_Query + "and Cname like "& CName &"
end if
-- I can't remember if the operator should be "+" or "&&" , you have to check .
All the above are just a rough concept. Hope it helps.