Moving subform to last record

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

Guest

I have an Access 97 Database

I have a form with a subform. The subform is a single form (not continuous).

What code would I write so that whenever I move to a new record on the main
form (On Current Event) that it navigates to the last record of the subform?

Thanks if you have an answer

Mark
 
Mark,

I assume that your subform is not bound to your main form. It would not
normally be likely that a subform would contain records if the main form is
on a new record. What I frequently do is actually hide the subform until the
user has saved the main form.

Assuming you actually want to do what you posted, you might try something
like the following, where "your_subform" is actually the name of the control
holding the subform.

Private sub Form_Current

dim rs as doa.recordset
set rs = me.your_subform.form.recordsetclone
if not rs.eof then rs.movelast
rs.close
set rs = nothing

end sub

HTH
Dale
 
Mark,
I think this will do it:
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
If Me.NewRecord Then
Set rst = Me.Controls("subformname").Form.Recordset
If rst.EOF = False Then
rst.MoveLast
End If
End If
Set rst=Nothing
Set dbs=Nothing

Geof.
 
Back
Top