Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find record number of record that matches criteria?

Status
Not open for further replies.

legos

Programmer
Jul 2, 2003
151
US
hi i have 4 values: Xmin, Xmax, Ymin, Ymax
i want to find the recordnumber of a record that matches this criteria, something like this.
Set rst2 = db.OpenRecordset("Select * FROM LASouth WHERE Field2 > Xmin AND Field2 < Xmax AND Field3 > Ymin AND Field3 <Ymax")
num = rst2.recordnum
all of the values are doubles. What do i need to change to get this code in working order?

Durible Outer Casing to Prevent Fall-Apart
 
i want to find the recordnumber of a record
There is no reliable record number for tables row.
The usual way is to play with PK (primary key).
Assuming you have a column ID of type autonumber, you may try something like this:
Set rst2 = db.OpenRecordset("Select * FROM LASouth WHERE Field2>" & Xmin & " AND Field2<" & Xmax & " AND Field3>" & Ymin & " AND Field3<" & Ymax)
If Not rst2.BOF And Not rst2.EOF Then
num = rst2("ID")
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
problem is, i keep getting an expected list seperator or ) error. anybody see where it is? once again px,x1,py,y1 are doubles.
Set rst2 = db.OpenRecordset("Select * FROM LASouth WHERE _
Field2 < "& Px &" _
AND Field2 > "& x1 &" _
AND Field3 > "& Py &" _
AND Field3 < "& y1 &")

Durible Outer Casing to Prevent Fall-Apart
 
At first glance, you need a semi-colon at the end of your SQL statement.
("Select * FROM LASouth WHERE Field2>" & Xmin & " AND Field2<" & Xmax & " AND Field3>" & Ymin & " AND Field3<" & Ymax & ";")
Hope this helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top