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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find record in array

Status
Not open for further replies.

thompom

Technical User
Dec 4, 2006
395
GB
hi - this might be a stupid question but am new to arrays,
have an array from a recordset using getrows.

i know how to loop through the array to list all records but what if i want to display a specific record from the array - do i have to loop through all records anyway?

at the moment i think it should be

Code:
for j2=0 to UBound(kcus, 2)
if x_carid = kcus(5,j2) then j2 = j3 end if
next

x_fname = kcus(0,j3)
x_lname = kcus(1,j3)
x_lname = Left(x_lname,8)
x_pcode = kcus(3,j3)
x_reg = kcus(4,j3)

if im not making sense let me know!
 
a wise man once told me, "there are no such thing as stupid questions."

if you know the exact index of your record, and you are positive it will never change, then of course you can reference it directly. if, however, you are testing for a specific condition, you will need to loop through. you can always use an exit statement to prevent further looping after you've found the data you need.



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
hi cLFlaVA - thanks for your reply
the index changes so i will loop.
and an exit statemement is a good idea,
thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top