How do you show the last record on a subform

M

morgan

I have a Form that has a subform on it. How do you show
last record to be ready for data entry, when the form
opens?
 
G

Gary Miller

Set the subform to be DataEntry = Yes in the Data properties
of the form.

--

Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
 
G

Guest

What I ment was, when the form opens I want the last
record showing, I don't realy want to enter data in it, I
just want the last record showing.
 
I

Ian Baker

Hi Morgan
I recently had a similiar problem where I wanted the subform to fill with
records with the new record entry row displayed at the bottom of the subform
regardless of how many records were in the subform. This is what I have
done:
Notes:
I placed the following code in the OnCurrent event of the main form
My subform is sized to display 12 records and the new record hence the No 13
in the code below
I have a control on the main form which I will call MyControl

Dim X As Integer

'Set focus to the subform
Me!MySubform.SetFocus

'Count the number of records in the subforms recordset - note you could
also include .MoveLast
X = Me!MySubform.Form.RecordsetClone.RecordCount

'If the subform has more then the display capacity then go to the new
record and then go back
'to the first record that will be at the top of the subform display then
go back to the new record
'so when you enter the subform you will go to the new record ready to
enter one
If X > 13 Then
DoCmd.GoToRecord , , acNewRec
DoCmd.GoToRecord , , acGoTo, X - 10
DoCmd.GoToRecord , , acNewRec
Else
DoCmd.GoToRecord , , acNewRec
End If

'Go back to the main form and set the focus to the first control on the
main form
Me!MyControl.SetFocus

It may not be the most glorious way of doing it but at least I know it works

Hope this helps
 
G

Gary Miller

Not what you asked the first time...

"How do you show last record to be ready for data entry,
when the form opens?"

If you don't mind having the last entered record at the top
instead of the bottom, create a simple one table query for
your subforms data and set it to your ID or entry date DESC
and base your subform on that.

--

Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
 

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