Up and Down Arrows to work on a form

S

SteveInBeloit

Hello,
I have a continueous form that allows entery. They users fill in the fields
and tab to the next field. There are 8 fields, but only the first three are
required. Once the user fills in the first three, they want to be able to
hit the down arrow and jump down to the next line and start inserting the
next record. They have this capability in their Access97 app. I am using Xp

Any thoughts on how to do this?

Thanks,
Steve
 
A

Allen Browne

Set the form's KeyPreview property to Yes.
You can then use the KeyDown event of the form to trap the up/down arrows,
and move record.

In practice, there's a bit more to it than that. If the current record is
dirty, Access has to save it before it can move record. The save could fail
(validation rules, required fields, unique indexes, ...) The save also
triggers an entire chain of events: the events for the control(Change,
BeforeUpdate, ...) and for the form (BeforeUpdate, ...). The chain can give
problems that you can avoid if you explicitly save the record rather than
attempting to move first.

Some other issues to address include:
- How to respond if Form.ActiveControl is in the Header or Footer of the
form, not the detail section.
- How to respond if the active control is a multi-line text box, so the user
expects the arrow to move to the next previous line in the control instead
of moving record.
- How to respond if the active control is a list box or dropped-down combo,
so the user expects the arrows to select the previous/next row of the combo
rather than change records.

To save record:
If Me.Dirty Then Me.Dirty = False

To test if the control is in the detail section:
If Form.ActiveControl.Section = acDetail Then

To test if the control is multi-line, examine its EnterKeyBehavior and
Scrollbars properties.

Determining the dropped-down state of a combo is a bit more involved:
http://www.mvps.org/access/api/api0052.htm
 
S

SteveInBeloit

Allen,
Thank you. That is some great information that I did not know. Based on
your response, I have it working. Now just need to check for some of the
other conditions you described.
Thanks again,
Steve
 
Top