Subform bottom to top

L

Lars Brownies

I have a continous subform that shows records from top to bottom. When the
subform exceeds more than 3 records, the yet to be made record is hidden so
users have to scroll down to enter a new record. Is there a possibility to
have the records shown bottom up, so that I always see the new record?
Thanks,
Lars
 
J

Jack Cannon

You cannot display the records "bottom up" if the objective is to show the
new record line at the top. You may be able to achieve your objective of
preventing the need to scroll by using one of these two commands within the
OnLoad event of the form.

DoCmd.GoToRecord acDataForm, "MyForm", acLast

DoCmd.GoToRecord acDataForm, "MyForm", acNewRec

Jack Cannon
 
L

Lars Brownies

Thanks. I tried these 2 options from the main form but I keep getting the
error:

"The object 'xxx' isn't open."

Lars
 
J

Jack Cannon

Sorry, since you are using a subform then you must have the GoToRecord
command in the OnLoad event of the subform not the main form. Also the
GoToRecord command must refer to the subform.

You cannot display the records "bottom up" if the objective is to show the
new record line at the top. You may be able to achieve your objective by
using one of these two commands within the OnLoad event of the form.

DoCmd.GoToRecord acDataForm, "MySubForm", acLast

DoCmd.GoToRecord acDataForm, "MySubForm", acNewRec

Jack Cannon
 
L

Lars Brownies

If I´d place the code in the subform´s Onload, it wil only fire once and I
need it to fire every time a new record is selected in the main form. I
managed to put code in the main form´s oncurrent event using a
recordset.movelast for the subform. So now it jumps to the last subform´s
record. I haven´t figured out yet how to move to a new record, on the other
hand I´m not sure if I would want that anymore.

Lars
 
L

Lars Brownies

Clever idea! Thanks. Will do so.
Lars

Steve said:
Hello Lars,

Create another subform that can add records to the same table as your
existing subform. Insert the new subform just above your existing subform
and make it only one line. This is where you will add new records. In the
subform's AfterUpdate event, requery the existing subform. Also set the
Allow Additions property of the existing subform to No.

Steve
(e-mail address removed)
 
L

Lars Brownies

FYI: I fiddled around some more and got off of the idea to have the input at
the top. The following seems to work well.

In the main form's Oncurrent I put:

If Me!MySub.Form.Recordset.RecordCount > 0 Then
Me!MySub.Form.Recordset.MoveLast
Me!MySub.Form.Recordset.AddNew
End If

My subform can show up to 3 records. With this code the 2 last entered
subformrecords (if they exists) show, and a new record at the bottom. It
works pretty well.

It needs << Me!MySub.Form.Recordset.MoveLast >> otherwise it sometimes shows
only the new record and not the existing ones. The recordcount is needed as
movelast will cause a 'no current record' error on MoveLast.

Lars
 
G

Gabriel Quero

Jack Cannon said:
Sorry, since you are using a subform then you must have the GoToRecord
command in the OnLoad event of the subform not the main form. Also the
GoToRecord command must refer to the subform.

You cannot display the records "bottom up" if the objective is to show the
new record line at the top. You may be able to achieve your objective by
using one of these two commands within the OnLoad event of the form.

DoCmd.GoToRecord acDataForm, "MySubForm", acLast

DoCmd.GoToRecord acDataForm, "MySubForm", acNewRec

Jack Cannon
 

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