Assigning a different role to keys

V

Victoria

I enter data that is read to me into a subform with several textboxes. I
have the cycle property set so that the cursor cycles through all the
textboxes without moving on to the next record. We want it this way since we
use the 2nd time through to read the values back as a check cycle. I then
have to click buttons to move to the Next or Previous record. This clicking
really slows things down. All the data is keyed into the numeric keypad, so
I want to use the adjacent PageUp or PageDn buttons to move to the Next or
previous records. QUESTION: How can I reassign this role to these buttons?
Oh ya - ideally, these buttons should only have their roles changed when
this form is open.

I'm a bit new at this, so don't be afraid to spell things out!
thanks
 
M

missinglinq via AccessMonster.com

In the code behind the form place this code:

Private Sub Form_Load()
Me.KeyPreview = True
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

Select Case KeyCode

Case vbKeyUp
DoCmd.GoToRecord , , acNext

Case vbKeyDown
DoCmd.GoToRecord , , acPrevious

End Select

End Sub
 
A

Al Campagna

Victoria,
Place a button on your subform, Name it cmdNextRecord, and give it a Caption of &N
(You can hide the button if you want)

Using the Button's OnClick event, code it to go to the Next Record.

Private Sub cmdNextRecord_Click()
DoCmd.GoToRecord , , acNext
End Sub

While editing/reviewing the subform record, whenever you want to go to the Next record,
just hit Alt+N. Because the button Caption is &N, Alt+N will "fire" the button's code.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

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