473,503 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Search for record between two fields (Access)

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
Sep 5 '08 #1
1 2722

"David" <da*********@scene-double.co.ukwrote in message
news:e5**********************************@f36g2000 hsa.googlegroups.com...
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
Sep 5 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3517
by: CharitiesOnline | last post by:
Hello, I have set this script up to add paging to a search results page. Which on the first page works fine. I calculates how many pages there should be depending on the number of results returned...
4
1666
by: Captain Wonky | last post by:
As the subject says... I'm a database novice even though I've been trying to learn Access for years. I've 'almost finished' several databases but always get stumped on something - this time it's...
1
1801
by: Jack-of-all-traits | last post by:
This is a big problem and I really need help, no one seems to know how to solve this problem. I want to take the data from a record in a particular a field that contains the names of generic...
1
4153
by: Average Bear | last post by:
If anyone could help with this one, I am a bit puzzled. I understand you can create an index using two fields of a database, then use the seek method to find a record based on both fields. My...
8
3195
by: Steph | last post by:
Hi. I'm very new to MS Access and have been presented with an Access database of contacts by my employer. I am trying to redesign the main form of the database so that a button entitled...
5
4170
by: JP SIngh | last post by:
Hi All This is a complicated one, not for the faint hearted :) :) :) Please help if you can how to achieve this search. We have a freetext search entry box to allow users to search the...
4
3545
by: RoadRunner | last post by:
Hi, I have a question. I am asked to produce a global search of a given corporate name, in more that one database. Each database has different table names and different field names in the tables....
1
2708
by: Eric | last post by:
Hi: I have two files. I search pattern ":" from emails text file and save email contents into a database. Another search pattern " field is blank. Please try again.", vbExclamation + vbOKOnly...
1
11657
by: atl10spro | last post by:
Hello Everyone, I am new to MS Access and although I have created several different databases I lack the VB knowledge to code a search function. I am turning to your expertise for assistance. ...
1
2487
by: gautam89 | last post by:
Hi everyone... I'm a high school student working on an Access project for a summer internship. I needed your assistance in writing a criteria for a select query. Table1 has the following...
0
7203
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7089
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7463
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5017
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3157
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1515
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
389
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.