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!

Docmd.Findrecord will not work on subform 2

Status
Not open for further replies.

RichD

Programmer
Sep 3, 2002
150
0
0
GB
I am trying to use docmd.findrecord to move to a particular record in a sub form, but cannot get it to work.

I have a form 'Employees' and a datasheet subform containing salary levels. When the user moves to a different employee I want the subform focus to move to the first record where the salary > 0. This is (part of) my code
in the mainform's On Current event

dim rstc as recordset, firstpoint as Variant
Set Rstc = forms!mainfrm!subform.form.Recordsetclone
rstc.findfirst "Salary >0"

firstpoint = rstc!Points
set rstc = nothing

forms!mainfrm!subform.form!Points.setfocus
docmd.FindRecord firstpoint

When I run this I get "Runtime error 2162, A macro set to one of the current fields properties failed because of an error in a FindRecord Action Argument."
I have tried setting various arguments without any success I always get the same message.


I have used a similar method successfully in Access 97 but cannot get the above to work in Access2000.

Any help greatly appreciated.

Rich

Lead Developer
 
This will do what you ask.

Private Sub Form_Current()
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone

rs.FindFirst "PAY1 > 0"

Me.Bookmark = rs.Bookmark

rs.Close
Set rs = Nothing
End Sub

I just tried it. It will not let you do anything but sit on this record but it does what you ask.

Any further questions???


rollie@bwsys.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top