Moving subform to last record

M

Mark

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
 
D

Dale Fye

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
 
G

Geof Wyght

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.
 

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