You're right - I should have realised that if it has a Find method, rather
than FindFirst, FindNext etc. methods, it has to be an ADO recordset.
The other way to do a multiple criteria search is to specify the criteria
in the SQL statement when opening the recordset, but if your recordset is
a clone you never open it, so that option isn't available to you.
Filtering the recordset is no great chore, though.
If your recordset is a clone, it is instantiated when you clone it.
Perhaps an example might help to clarify ...
Private Sub Command18_Click()
Dim rst As ADODB.Recordset
'Recordset instantiated here ...
Set rst = Me.Recordset.Clone
'Don't ask ...
rst.Filter = "Address1 = 'Gelipemanu' AND Address2 = 'Xidutogo'"
If rst.EOF Then
MsgBox "No matching record"
Else
Me.Bookmark = rst.Bookmark
End If
End Sub
--
Brendan Reynolds (MVP)
kdw said:
My understanding was that Find is an ADO method and Findfirst is DAO. I
would like to keep all of my codes as ADO. Is there no other way around
doing a multiple criteria search?
But you are right about the error not relating to the Find method. I
haven't instantiate rst. But "Set rst = New Recordset" wouldn't work
either
because if I do that, wouldn't I be trying to do a search on a new
recordset
with nothing in it? Should I do a recordset clone first?
Brendan Reynolds said:
If this is a DAO recordset, your syntax is correct. (There's a double
quote
missing from the end, but I think that's just a typo in the newsgroup
posting - otherwise you'd be getting a different error message). If this
is
an ADO recordset, you can't do that, the ADO Find method accepts only a
single condition, you have to use Filter for multiple conditions.
I suspect the error you're seeing has nothing to do with the Find
syntax - I
think you haven't instantiated your recordset. If this is a DAO
recordset,
do you have an OpenRecordset statement in the code prior to the code you
posted? Or if it is an ADO recordset, do you have a Set rst = New
Recordset
statement prior to the code you posted?
--
Brendan Reynolds (MVP)
what is the correct syntax for using mulitple criteria for the Find
method?
I tried:
sTemp = "[FirstName] = '" & Me!First & "' AND [LastName] = '" &
Me!Last &
"'
rst.Find (sTemp)
If rst.EOF = False Then
Me.Undo
Me.Bookmark = rst.Bookmark
End If
and got a run-time error 91 - Object variable not set.
What I want to do is go to the existing record on the form if the user
typed
in a name that already exist. Is there a better approach?
Thanks in advance!