Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Search for record between two fields (Access)

Reply
Thread Tools

Search for record between two fields (Access)

 
 
David
Guest
Posts: n/a
 
      09-05-2008
Hi,

I have a table called 'jobserial'

This contains amongst others, 2 fields called 'PSL_F_Serial' &
'PSL_L_Serial'
Both of these are 'Text' fields (VarChar) which at present hold serial
numbers

I have a form on my ASP page which loads the new serials into the
Access database as a range only, i.e. The first serial in the range
(from TEXTBOX1) loads into 'PSL_F_Serial' and the last serial in the
range (from TEXTBOX2) loads into 'PSL_L_Serial'
Only these 2 numbers are stored per record in the table.

I need an SQL statement that will check the 2 serial numbers entered
against matching serials in 'PSL_F_Serial' & 'PSL_L_Serial' and also
BETWEEN 'PSL_F_Serial' & 'PSL_L_Serial'.

i.e. if record 52 exists as :

PSL_F_Serial = 0908216206
and
PSL_L_Serial = 0908216245

so, in theory, there are 40 serial numbers including the first & last
in this range, but only the first & last are stored.

Then when the user enters a number in Textbox 1 and 2 it needs to find
out if

Text box1 = 0908216206 or 0908216245....RECORD FOUND
Text box2 = 0908216206 or 0908216245....RECORD FOUND
and
If user enters any number BETWEEN 0908216206 & 0908216245 in textbox1
or 2 ..... RECORD FOUND

Could you show me how ? thanks .... this one is really important, as
at present, duplicates are getting into the DB if the number entered
is BETWEEN the range, as I have not worked out how to catch them !

Many thanks in advance

David
 
Reply With Quote
 
 
 
 
Ron Hinds
Guest
Posts: n/a
 
      09-05-2008

"David" <> wrote in message
news:e5b52c3a-76ee-442a-a789-...
> Hi,
>
> I have a table called 'jobserial'
>
> This contains amongst others, 2 fields called 'PSL_F_Serial' &
> 'PSL_L_Serial'
> Both of these are 'Text' fields (VarChar) which at present hold serial
> numbers
>
> I have a form on my ASP page which loads the new serials into the
> Access database as a range only, i.e. The first serial in the range
> (from TEXTBOX1) loads into 'PSL_F_Serial' and the last serial in the
> range (from TEXTBOX2) loads into 'PSL_L_Serial'
> Only these 2 numbers are stored per record in the table.
>
> I need an SQL statement that will check the 2 serial numbers entered
> against matching serials in 'PSL_F_Serial' & 'PSL_L_Serial' and also
> BETWEEN 'PSL_F_Serial' & 'PSL_L_Serial'.
>
> i.e. if record 52 exists as :
>
> PSL_F_Serial = 0908216206
> and
> PSL_L_Serial = 0908216245
>
> so, in theory, there are 40 serial numbers including the first & last
> in this range, but only the first & last are stored.
>
> Then when the user enters a number in Textbox 1 and 2 it needs to find
> out if
>
> Text box1 = 0908216206 or 0908216245....RECORD FOUND
> Text box2 = 0908216206 or 0908216245....RECORD FOUND
> and
> If user enters any number BETWEEN 0908216206 & 0908216245 in textbox1
> or 2 ..... RECORD FOUND
>
> Could you show me how ? thanks .... this one is really important, as
> at present, duplicates are getting into the DB if the number entered
> is BETWEEN the range, as I have not worked out how to catch them !
>
> Many thanks in advance
>
> David


If you really mean OR here:

> If user enters any number BETWEEN 0908216206 & 0908216245 in textbox1
> or 2 ..... RECORD FOUND


use the statement below as-is. But I think what you really want is AND; if
so, just change the OR below to AND. The rest is assuming you already know
how to open a connection and a recrodset...

strSQL = "SELECT PSL_F_Serial, PSL_L_Serial FROM jobserial WHERE ('" &
TextBox1 & "'>=PSL_F_Serial AND '" & TextBox1 & "<>=PSL_L_Serial) OR ('" &
TextBox2 & "'>=PSL_F_Serial AND '" & TextBox2 & "<>=PSL_L_Serial)

rs.Open strSQL, cn, adOpenDynamic, adLockOptimistic

If rs.EOF Then
'Record not found
Else
'Record found
End If


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
| SEO , Search Engine Optimizer, SEARCH OPtiMIzAtIoN with SeaRch OPtiMizer optimizer.seo@gmail.com Digital Photography 0 04-22-2007 04:20 AM
Search Across Two Concatenated Fields e_marquess@hotmail.com ASP General 1 08-10-2006 11:52 PM
Newbie - Reading a file with delimited fields, storing first two fields in a hash AMT2K5 Perl Misc 1 11-08-2005 01:06 AM
search within a search within a search - looking for better way...my script times out Abby Lee ASP General 5 08-02-2004 04:01 PM
Can Altova mapforce be used to map fields between two RDF (Resource Definition Framework) XML files? Michael Herman \(Parallelspace\) XML 0 12-28-2003 01:13 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57