How to position records in a scrolling subform

D

DianePDavies

I Have a mainform with a subform shown as "Continuous Forms". The subform
shows a line for each record.

My subform is tall enough to display 10 records.

In my subform I can scroll through the records, and when I come to my last
record I can keep scrolling until only one = the last record is shown in my
subform.

When I (through code) insert a new blank record at the end - my subform
clears and shows just this one record (as if I scrolled all the way to the
last record).

I would like the subform to display the last 10 records - including my new
one at the bottom.

How do I specify the number of records displayed in my subform?
 
A

Al Campagna

Diane,
I set up a test situation where my subform's Form Header contained a
button named NewRecord. You should be able to merge my code into
your code when you wnat a new record.
I also placed a calculated field in the Form Header named NoOfRecs
with...
=Count(*)
My sub was only 10 records high...

Forms!frmAddresses!frmAddressesTelephoneSub.Form!TelDesc.SetFocus
If NoOfRecs >= 10 Then
DoCmd.GoToRecord , , acNewRec
DoCmd.GoToRecord , , acPrevious, 9
DoCmd.GoToRecord , , acNewRec
Else
DoCmd.GoToRecord , , acFirst
DoCmd.GoToRecord , , acNewRec
End If

I tested this code on 7 sub recs, 15 sub recs, etc... and it should be
OK.
Please "tweak" (if necessary), but that's the general concept.

--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
D

DianePDavies

I tried that - and to some extent it works - but in my case it requires me to
move the focus around between my main form and the sub form. It is not a very
"clean" way of doing it... Isn't there some way of telling how many records
to show?
 

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