findFirst record bookmark not working

P

pampas

Hello,

I am trying to keep focus in a specific record in
frmDetalheMovFinanc , and it works fine if i set breakpoints in my
code. But when I clear all break points, it moves focus in that
subform to another record

Can you help me
Thanks
Carlos

Code that I have in the OnCurrent event of my form

On Error Resume Next

If Not IsNull(Me.OpenArgs) Then
Dim pass
Dim frm As Form

pass = Me.OpenArgs
pass = Eval(pass) ' if i dont do this it reads a string


Set frm = Forms![frmMovFinanc]![frmDetalheMovFinanc].Form
frm.Requery ' if i put a break point here the code works fine and when
the form opens in the desired record

With frm.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "DetalheMovID =" & pass
frm.Bookmark = .Bookmark
End If
End With
Set frm = Nothing
End If
 
G

Guest

Carlos,

What code are you using to open the form?

My recommendation is that if you want to open the form to a particular
record, you should use the WhereCondition of the OpenForm method.

docmd.OpenForm "formName",,,"DetalheMovID] =" & pass

If you need to open the form so that all records are visible, but so that it
goes to the selected record, you are on the right track. First, you need to
define the Pass variable as a number (probably long). Second, you don't need
to define the form if the code is in that forms code module, just refer to
the form as Me (and I would put this code in the forms Open event). I'm not
sure why you have the code setting the frm variable and requerying the form,
so I have commented it out.

If Not IsNull(Me.OpenArgs) Then

Dim pass as Long
Dim rs as Dao.recordset

pass = clng(Me.OpenArgs)

'Set frm = Forms![frmMovFinanc]![frmDetalheMovFinanc].Form
'frm.Requery ' if i put a break point here the code works fine and when
'the form opens in the desired record

Set rs = me.recordsetclone
With rs
.FindFirst "DetalheMovID =" & pass
if .nomatch then
msgbox "not found!"
else
me.Bookmark = rs.Bookmark
End If
End With

End If

HTH
Dale
 
P

pampas

Hi Dale,

I still have the same problem . It works fine with breakpoints, but
not without
What code are you using to open the form?
I'm opening one form from another, passing the criteria using
OpenArgs

on the afterUpdate event of the first form (Forms![frmMovFinanc]!
[frmDetalheMovFinanc].Form)
DoCmd.OpenForm "frmDetalheCC", , , acDialog, OpenArgs:=Me.DetalheMovID

then in the load event of the 2nd form (frmDetalheCC), i am trying to
setfocus in the record i just left in the first Form
with the unique identifier stored in variable Pass

Carlos
 

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