so myArray() contains a list of ID's ?
is the array built for IDs in another table / query ?
if so execute,
strsql = "select ID from tblMain where salary = '"
strsql = strsql & varSomeValue & "' and "
strsql = strsql & "ID IN (SELECT ID from othertable where ....)"
set rrst = currentdb.openRecordset(strsql)
if the array isn't built from another table, and it doesn't have too many items
convert the array contents into a comma-delimited string
ie. array(0) = 1
array(1) = 20
strArray = "'1','20'"
strsql = "select ID from tblMain where salary = '"
strsql = strsql & varSomeValue & "' and "
strsql = strsql & "ID IN (" & strArray & ")"
set rrst = currentdb.openRecordset(strsql)
"Deano" <de*********@hotmail.com> wrote in message news:<y2*******************@stones.force9.net>...
I think my brain has short-circuited again :)
Is this the quickest way to check for the existence of a given value in an
array?
e.g
For i = 0 To rrst.RecordCount
If myArray(i) = DLookup("ID", "tblmain", "Salary = " &
varSomeValue) Then
Exit sub
End If
Next
I would like this lookup to be a bit quicker. This code means looping
through every item in the array - is there a shortcut or is this OK?
thanks
Martin