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!

VBA - Access 2002 - Code worked in '97 but I now get an error....

Status
Not open for further replies.

mrgrogro

Technical User
Jan 8, 2005
58
0
0
US
I have an Access 2002 database I am working on but, alas, have practically no knowledge of VBA. I am using the following code to find a record on one form using a combo box on another form. I got this here many years ago and it seemed to work in Access 97. Here is my code:

Private Sub Box9_Click()

Dim db As DAO.Database, rst As DAO.Recordset
Dim frm As Form, Criteria As String

Set db = CurrentDb()
Set frm = Forms![frmSearchbyPosition]
Set rst = frm.RecordsetClone

Criteria = "[Position]='" & Me![Position] & "'"
rst.FindFirst Criteria

frm.Bookmark = rst.Bookmark

Set rst = Nothing
Set frm = Nothing
Set db = Nothing
DoCmd.Close

End Sub

Now when I click the button, I get the following message:

Run-time error '7951'
You entered an expression that has an invalid reference to the Recordset Clone property.

Any ideas to resolve this issue would surely earn a star and my deep gratitude. Thanks in advance
 
Why not simply this ?
Code:
Private Sub Box9_Click()
Forms![frmSearchbyPosition].Recordset.FindFirst "Position='" & Me!Position & "'"
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
BTW, does frmSearchbyPosition really have a RecordSource property ?
In other words, is frmSearchbyPosition bound ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top