New record at the top of a continuous form

A

Ascerbus

I have a form with two subforms on it. The first subform is continuous
and shows relevant data with an ORDER BY dtmDate DESC clause to show
most recent entries first. Items cannot be added to this subform but
may be edited since I don't think that I can have a new record entered
as the first line of this continuous form.

I created a workaround to this problem by creating a second subform,
sized so that it appears to be a part of the first subform with only
one record line showing. This subform is set to Data Entry = Yes. All
of this works well enough, however when I enter a new record line on
the data entry subform, it appears to the user that the data has
disappeared. It actually hasn't -- it is just appears this way since
the subform is sized to only show one record line at a time.

What I would like these two subforms to do is have the bottom subform,
with descending by date data listed continuously, update automatically
when I leave the last field of the record in the top data entry
subform. The way I have it set up now is that there is a command
button which refreshes the entire form so that the new entry appears on
the bottom subform -- it works but it is sloppy. The refresh code that
is under this button (generated by the wizard) does not work when
placed on the OnExit Event for the last control in the record of the
top subform.

Am I placing the code in the wrong event? Is there another bit of code
that I should use instead of the generated Refresh code? Is there a way
to actually use one subform and force a new record to show at the top
of the series of a continuous form? I am pretty new to Access so please
be gentle and describe any solutions to me in terms that a Martian
would understand. Thank you.

---Tim Dunne
 
G

Guest

I'd suggest you use the AfterInsert event procedure of the second subform.
That way it will fire when a new record is entered. In the code Requery the
first subform control. Subform control here means the control in the parent
form's Controls collection which houses the first subfrom. You can refer to
the parent form from the second subform's module by means of the Parent
property, so the code would be something like this:

Me.Parent.FirstSubformControl.Requery

Ken Sheridan
Stafford, England
 
T

Tim Dunne

AfterInsert worked like a charm. I also added Me.Requery to prevent
users from shift-tabbing back on the DE subform. Thank you for the
help.
 

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