-----Original Message-----
Hi Dan,
If you are trying to identify the condition where there are no matches for
cbocarNumber I'd probably go with a Dlookup statement. Recordsets are
wonderful but I wouldn't open one if this is the sole purpose for opening
it. Assuming that you need the recordset for something other than this
lookup, here's some aircode:
dim MyData as DAO.recordset
dim MyDB as DAO.database
set myDb=currentdb
set mydata=mydb.openrecordset("Select * from tblExtensionInfo;")
with Mydata
.findfirst "carNumber=" & cboCarNumber
if not .nomatch then
'do what you want when
'there are no matches
else
'do whatever you want if there are
'matches
endif
.close
end with
Several things to note:
- Findfirst will not work with a tabletype recordset. Hence the "Select *. .
..". You could also use the name of a query in place of the SQL
- Instead of "select *" with no criteria, in practice I'd use a where clause
to restrict the data as much as possible.
- if your search field (presumably 'carNumber') is actually text then the
test value must be wrapped in quotes:
..findfirst "carNumber=""" & cboCarNumber & """"
Hope this helps you -
--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.
Hi,
The following code uses the seek method to find where the
value in cboCarnumber does not match any records in
tblExtensionInfo.
Set Mydata = MyDB.OpenRecordset("tblExtensionInfo"):
MydataOpen = True
Mydata.Index = "carSearch": Mydata.Seek "=", cbocarNumber,
Null
How would I change this statement from Seek to the
Findfirst method?
Thanks in advance for your help.
.