Continuos Subform SetFocus to a certain record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
If anyone can help it would be great,

I have a subform on my main form. The subform is continuous and each record
on the subform has a button that takes you to a different for to edit the
record, my problem is once the user goes back to the form, it must refresh,
and when this happens it resets the current record to the first one.
How can I set the current record on the subform after the form has been
refreshed to set the focuse to the record that it was on before.

i have stored the primary key in a variable, and have tried using the
gotorecord command but it doesn't seem to be working when i call it from the
main form.


Any suggestions would be great,

Thanks
~T
 
Tamiyra said:
I have a subform on my main form. The subform is continuous and each record
on the subform has a button that takes you to a different for to edit the
record, my problem is once the user goes back to the form, it must refresh,
and when this happens it resets the current record to the first one.
How can I set the current record on the subform after the form has been
refreshed to set the focuse to the record that it was on before.

i have stored the primary key in a variable, and have tried using the
gotorecord command but it doesn't seem to be working when i call it from the
main form.


Me.subform.Requery
With Me.subform.Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "pkfield = " & pkvariable
If Not .NoMatch Then
Me.subform.Bookmark = .Bookmark
End If
End If
End With

If the pkfield is a text type field, then use this:
.FindFirst "pkfield = """ & pkvariable & """"
 
Thanks Marshall

Just a quick fix to the code if anyone is searching for a similar solution:



Me.subform.Requery
With Me.subform.Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "pkfield = " & pkvariable
If Not .NoMatch Then
Me.subform.form.Bookmark = .Bookmark
End If
End If
End With

If the pkfield is a text type field, then use this:
.FindFirst "pkfield = """ & pkvariable & """"
now it works great was missing a .form when setting the bookmark


 
Tamiyra said:
Just a quick fix to the code if anyone is searching for a similar solution:


now it works great was missing a .form when setting the bookmark


Good catch. Much faster than the usual followup -
"it didn't work" ;-)

Sorry for any time you wasted on my mistake.
 
Back
Top