Form results contains or begins with

S

SS

Hi

I have a form which works fine and searches a telephone list database as
long as I type the whole first name or last name.

We have quite a few foreign students so I would like to be able to search
just on the beginning of a name. I've tried changing the search criteria to
Contains or begins with but the whole database comes up.

What should I set thecriteria to?
Thanks
Shona
 
S

Stefan B Rusynko

Your criteria should use Like (the 1st letter of the form field) instead of Equals
So if you now have
strsql = "where name='" & Request.Form("namefield"") & "'"
Change it to
strsql = "where name='" & Request.Form("namefield"") & "' OR name Like '" & Left(Request.Form("namefield""),1) & "%'"

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| Hi
|
| I have a form which works fine and searches a telephone list database as
| long as I type the whole first name or last name.
|
| We have quite a few foreign students so I would like to be able to search
| just on the beginning of a name. I've tried changing the search criteria to
| Contains or begins with but the whole database comes up.
|
| What should I set thecriteria to?
| Thanks
| Shona
|
|
 
S

SS

Hi

Thanks for this but I tried Like to start with and that resulted in nothing

fp_sQry="SELECT * FROM Contacts WHERE (FirstName LIKE '::FirstName::' OR
LastName LIKE '::LastName::') ORDER BY LastName DESC"

As soon as I try to change this to what you have put as below it says that
when the page is saved the reults would be lost

fp strsql = "where name='" & Request.Form("FirstName"") & "' OR name Like
'" & Left(Request.Form("FirstName""),1) & "%'"
fp strsql = "where name='" & Request.Form("LastName"") & "' OR name Like '"
& Left(Request.Form("LastName""),1) & "%'"

any more ideas would be great

Cheers
Shona

I tried
 
S

Stefan B Rusynko

If using the DBRW you need to change it in the grey code part of the page, not in the ASP script part

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| Hi
|
| Thanks for this but I tried Like to start with and that resulted in nothing
|
| fp_sQry="SELECT * FROM Contacts WHERE (FirstName LIKE '::FirstName::' OR
| LastName LIKE '::LastName::') ORDER BY LastName DESC"
|
| As soon as I try to change this to what you have put as below it says that
| when the page is saved the reults would be lost
|
| fp strsql = "where name='" & Request.Form("FirstName"") & "' OR name Like
| '" & Left(Request.Form("FirstName""),1) & "%'"
| fp strsql = "where name='" & Request.Form("LastName"") & "' OR name Like '"
| & Left(Request.Form("LastName""),1) & "%'"
|
| any more ideas would be great
|
| Cheers
| Shona
|
| I tried
| | > Your criteria should use Like (the 1st letter of the form field) instead
| > of Equals
| > So if you now have
| > strsql = "where name='" & Request.Form("namefield"") & "'"
| > Change it to
| > strsql = "where name='" & Request.Form("namefield"") & "' OR name Like '"
| > & Left(Request.Form("namefield""),1) & "%'"
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > _____________________________________________
| >
| >
| > | > | Hi
| > |
| > | I have a form which works fine and searches a telephone list database as
| > | long as I type the whole first name or last name.
| > |
| > | We have quite a few foreign students so I would like to be able to
| > search
| > | just on the beginning of a name. I've tried changing the search
| > criteria to
| > | Contains or begins with but the whole database comes up.
| > |
| > | What should I set thecriteria to?
| > | Thanks
| > | Shona
| > |
| > |
| >
| >
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top