Force subform to always show first record

M

markv53

I have an unbound form with a combo box and a subform on
it. I use the combo box to select a customer and the
subform displays all customer order information. I have
it linked correctly with one small glitch.

When I select a customer with 10 orders all 10 orders show
properly in the subform. When I now select a new customer
with only 5 orders, the 5 orders show correctly but the
record pointer is at record #6. The record pointer is
trying to point to record #10 (the previous selection) but
since there are only 5 it moves to the new entry (blank)
record at the end of the data set (#6).

How can I force the subform to always show record #1 as I
make new selections in combobox regardless of how many
records are in the subform?

Thanks for any help
Mark
 
K

Kevin Sprinkel

When I select a customer with 10 orders all 10 orders
show properly in the subform. When I now select a new
customer with only 5 orders, the 5 orders show correctly
but the record pointer is at record #6. The record
pointer is trying to point to record #10 (the previous
selection) but since there are only 5 it moves to the new
entry (blank) record at the end of the data set (#6).
How can I force the subform to always show record #1 as I
make new selections in combobox regardless of how many
records are in the subform?

Hi, Mark.

Having just solved the exact opposite issue, i.e., going
to a new record, try:

DoCmd.GoToRecord , , acFirst

in the On Enter event of the subform control.

HTH
Kevin Sprinkel
 
G

Guest

Thanks Kevin, that works if I tab into (enter)the
subform. Is it possible to achieve the same result by
using the after update event in the combo box (i.e.
without having to tab into the subform?

I tried a few techniques like using bookmarks and
recordset clones but was unable to get the syntax correct.

Thanks for any further ideas
MarkV
 
K

Kevin Sprinkel

-----Original Message-----
Thanks Kevin, that works if I tab into (enter)the
subform. Is it possible to achieve the same result by
using the after update event in the combo box (i.e.
without having to tab into the subform?

I tried a few techniques like using bookmarks and
recordset clones but was unable to get the syntax correct.

Thanks for any further ideas
MarkV

Mark,

Assuming that each time you enter the subform, you can set
the focus to the subform control in the combo box'
AfterUpdate event:

Me!yoursubformcontrolname.SetFocus

The OnEnter event should take it from there, and put you
in the first record.

HTH
Kevin Sprinkel
 

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