Hi,
I'm attaching a form here. The user wants to be able to enter the data by column vs by row. For example, the would enter all "Net Sales" and then may go the column labeled "Bev Cup Sales" and enter in all of that data. Is it possible to do this and if so how do I do it?
Thanks!
Leesha
Tab order by column
-
- BronzeLounger
- Posts: 1488
- Joined: 05 Feb 2010, 22:25
Tab order by column
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Tab order by column
Not quite what you want, but near:
1) Set the Key Preview property of the form to Yes (in the Event tab of the Property Sheet).
2) Create a procedure in the form module or in a standard module:
3) Create an event procedure for the On Key Down event of each of the text boxes in the Detail section and call HandleTab from them:
etc. etc., with the actual names of your text boxes of course.
1) Set the Key Preview property of the form to Yes (in the Event tab of the Property Sheet).
2) Create a procedure in the form module or in a standard module:
Code: Select all
Sub HandleTab(KeyCode As Integer, Shift As Integer)
On Error Resume Next
If KeyCode = vbKeyTab Then
KeyCode = 0
If Shift And acShiftMask = acShiftMask Then
RunCommand acCmdRecordsGoToPrevious
Else
If Me.NewRecord Then
RunCommand acCmdRecordsGoToFirst
Else
RunCommand acCmdRecordsGoToNext
End If
End If
End If
End Sub
Code: Select all
Private Sub txtNetSales_KeyDown(KeyCode As Integer, Shift As Integer)
HandleTab KeyCode, Shift
End Sub
Private Sub txtEstRegSales_KeyDown(KeyCode As Integer, Shift As Integer)
HandleTab KeyCode, Shift
End Sub
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1488
- Joined: 05 Feb 2010, 22:25
Re: Tab order by column
Hi Hans,
I've never created a form module before so I figured I create a standard Module. Do I need to name it anything specific
Thanks!
Leesha
I've never created a form module before so I figured I create a standard Module. Do I need to name it anything specific
Thanks!
Leesha
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Tab order by column
You don't have to create a form module yourself - Access creates it automatically for you the moment you create an event procedure for the form or any of its components.
If you create a standard module (select Insert | Module in the Visual Basic Editor): the name of the module doesn't matter except that you shouldn't give it the same name as a procedure (Sub) or function - that would confuse VBA.
If you create a standard module (select Insert | Module in the Visual Basic Editor): the name of the module doesn't matter except that you shouldn't give it the same name as a procedure (Sub) or function - that would confuse VBA.
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1488
- Joined: 05 Feb 2010, 22:25
Re: Tab order by column
Hi Hans,
It doesn't look like my response posted. I'm so tired from looking at the computer all day I probably forgot to hit submit! First, this is awesome and works exactly the way I hoped it would! You are the best. Does this only work with the tab key or is it possible to put it on the down arrow? I figured I'd ask since it is inevitable that the user will ask for something else.
Thanks!
Leesha
It doesn't look like my response posted. I'm so tired from looking at the computer all day I probably forgot to hit submit! First, this is awesome and works exactly the way I hoped it would! You are the best. Does this only work with the tab key or is it possible to put it on the down arrow? I figured I'd ask since it is inevitable that the user will ask for something else.
Thanks!
Leesha
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Tab order by column
The line
tests whether the user pressed the Tab key. If you want it to work with the down arrow key, use
and if you want it to work with both:
Code: Select all
If KeyCode = vbKeyTab Then
Code: Select all
If KeyCode = vbKeyDown Then
Code: Select all
If KeyCode = vbKeyTab Or KeyCode = vbKeyDown Then
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1488
- Joined: 05 Feb 2010, 22:25
Re: Tab order by column
Thanks Hans!! What awesome code!!!
-
- BronzeLounger
- Posts: 1488
- Joined: 05 Feb 2010, 22:25
Re: Tab order by column
Since they use an accounting keyboard they hit the "enter" key and wanted to be able to use that to tab down. I tried "Or KeyCode = vbKeyEnter" to give it a shot but of course it didn't work. I was just stabbing in the dark.
Thanks!
Leesha
Thanks!
Leesha
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- BronzeLounger
- Posts: 1488
- Joined: 05 Feb 2010, 22:25
Re: Tab order by column
OH, so close :-)! Thanks