navigate subform

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

Guest

Is it possible to write a macro that will goto the next record in a subform?
Using the gotoRecord option brings up an error message saying that the form
is not open. Thank you in advance.
 
Use the GoToRecord method in the Open event of the subform and not the Open
event of the main form.
 
The subform is not open in its own right, i.e. it is not part of the Forms
collection.

It is therefore much easier to use code, where you can refer to the form and
its RecordsetClone. This example shows how a MoveNext button might look:

Dim frm As Form
Dim rs As DAO.Recordset

Set frm = Forms![Form1].[Sub1].Form
If frm.Dirty Then frm.Dirty = False 'Save first.

If frm.NewRecord Then
Beep 'Can't move forward any more.
Else
Set rs = frm.RecordsetClone
rs.MoveNext
If rs.EOF Then
Beep 'no more records.
Else
frm.Bookmark = rs.Bookmark
End If
End If

'Clean up
Set rs = Nothing
Set frm = Nothing
 
Back
Top