findfirst method - error

J

jakbrooklyn

I'm trying to use the findfirst method and keep getting a compile error -
"Method or Data member not found". I don't get it (OK, I'm an old cobol
programmer trying her hand at VB). Here's my code (thanks to a post by Paul
Johnson from 8/31/04!) :

Dim rst As Recordset

Set rst = CurrentDb.OpenRecordSet("SELECT CountryID, CountryName FROM
TCountries")
rst.FindFirst "CountryName = Forms!FCountries!CountryName" ' where MyID
is a control on

If rst.NoMatch = True Then
MsgBox "No match found for " & CountryName
Exit Sub
End If

TIA
 
W

Wayne Morgan

Change your Dim statement to

Dim rst As DAO.Recordset

DAO and ADO both have a Recordset object. Access will use the first one it
finds unless you specify which you want. If the Dim statement then gives you
a compile error, you will need to go into References (Tools|References) in
the code editor and place a check next to Microsoft DAO 3.6 Object Library.
 
J

jakbrooklyn

Wayne,
Thanks for your response. I did indeed get a compile error, and when I went
to the tools menu, references is disabled. Also - I'm guessing this is
related - when I tried to Dim a database I got an error as well.

Have I neglected to install something here????? Do you know what the prob is?
Anyone?
Thanks!
 
D

Douglas J. Steele

The References menu entry will only be enabled when you're in the VB Editor
(such as when you have a code module open). If the code is currently in
Break mode in Debug, you won't be able to get to the References. Try
clicking on the Reset button (or select Debug | Run from the menu) to ensure
that's not the case.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top