Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 New Filtering Problem - Please Help?
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Lycaster
New Member

USA
60 Posts

Posted - 26 April 2001 :  16:07:56  Show Profile  Visit Lycaster's Homepage  Send Lycaster an AOL message
I am trying to filter out records based on a keyword in a string. so here is what I am doing:

If Trim(Request("C_Type")) <> "" Then
sFilter = "[Career Type] LIKE '%" & (Request("C_Type")) & "%'"
Else
sFilter = ""
End If

If Trim(Request("E_Type")) <> "" Then
sFilter = "[Employment Type] LIKE '%" & (Request("E_Type")) & "%'"
Else
sFilter = ""
End If
Now when I pass the string it gives me all the records no matter what! Now if I only have one filter in the page it works fine. Why is it that when I have those 2 filters nothing works?

Thanks, Jared

e3stone
Average Member

USA
885 Posts

Posted - 26 April 2001 :  17:03:05  Show Profile  Send e3stone an AOL message
I'm slightly new to ASP, but don't you have to use the "WHERE" keyword or else it will return ALL records?

One question about your search: is that a nested filter? i.e. you can filter out the career types and then filter the employment types of those returns? Are values going to be passed to both C_Type and E_Type at the same time? Perhaps if I had a better understanding of what the form looks like that you're getting the variables from...do you have a link for the form that you're using?

Eric

Go to Top of Page

MorningZ
Junior Member

USA
169 Posts

Posted - 26 April 2001 :  17:03:10  Show Profile  Visit MorningZ's Homepage  Send MorningZ an AOL message
first off...
put the following two lines right before you execute the SQL

Response.Write theSQLString
Response.End

Then you can see whats going on and why the query "fails"....

To try to fix your code:

i see a slight prob with your code

If Trim(Request("C_Type")) <> "" Then
sFilter = "[Career Type] LIKE '%" & (Request("C_Type")) & "%'"
Else
sFilter = ""
End If

If Trim(Request("E_Type")) <> "" Then

if len( sFilter ) > 0 sFilter = sFilter & " OR " '<<<<<===== add this line

sFilter = "[Employment Type] LIKE '%" & (Request("E_Type")) & "%'"
Else
sFilter = ""
End If


-Steve


Go to Top of Page

Lycaster
New Member

USA
60 Posts

Posted - 27 April 2001 :  11:11:56  Show Profile  Visit Lycaster's Homepage  Send Lycaster an AOL message
MorningZ,

Thanks allot it worked after I made a few alterations:

If Trim(Request("E_Type")) <> "" Then
If len( sFilter ) > 0 Then
sFilter = sFilter & " OR "
sFilter = "[Employment Type] LIKE '%" & (Request("E_Type")) & "%'"
Else
sFilter = ""
End If
End If

It works like a charm!

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.26 seconds. Powered By: Snitz Forums 2000 Version 3.4.07