RecordsetClone on sub-Forms

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

Guest

I have a form with a continuous sub-form that is often longer than the space
allowed to diplay it. After I have updated a record, I can requery the form,
but how do I then move to the first item on the sub-form where a given field
is "TRUE"? I have tried RecordsetClone.Bookmark but am told that object does
not support the method. If I use doCmd.FindRecord, the program does not
recognise my field name as a valid name on the form.
 
Where is the code running from, the main form or the subform? If it is
running from the main form, you have to include the "path" to the subform in
the coding.

Example:
Me.NameOfSubformControl.Form.Recordset.FindFirst "[FieldName]=True"

The subform control is the control where you set the Parent/Child link
properties.
 
MikeT said:
I have a form with a continuous sub-form that is often longer than
the space allowed to diplay it. After I have updated a record, I can
requery the form, but how do I then move to the first item on the
sub-form where a given field is "TRUE"? I have tried
RecordsetClone.Bookmark but am told that object does not support the
method. If I use doCmd.FindRecord, the program does not recognise my
field name as a valid name on the form.

Where are you running the code, on the main form or on the subform?
That will make a difference in the way you refer to the subform and its
recordsetclone. If your code is running on the main form, it might look
something like this:

Dim frm As Access.Form

Set frm = Me!YourSubformControlName.Form

With frm.RecordsetClone
.FindFirst "[SomeField]=True"
If Not .NoMatch Then
frm.Bookmark = .Bookmark
End If
End With

Set frm = Nothing

Note: by "YourSubformControlName", I mean the name of the subform
control on the main form, the control that holds and displays the
subform. This may or may not be the same as the name of the form object
that is being displayed in that control.
 
Back
Top