Hi All,
This is really basic but I'm having trouble finding a straight forward way to do this. I have an Access application where the for is in spreadsheet mode. When a user leaves a control there is a series of calculations and the parent and child forms are refreshed. The cursor goes back up to the first control in the first record after refreshed and I bring it back to the original record using a bookmark.
My problem is that I need to determine where to put the cursor depending on the keystroke pressed. For example, if the user presses the down arrow key, I want the key to go to a certain control. If the user presses the tab key I want it to go to the next control in the record.
Can anyone help. Here is an example of the current code where I need to build this in.
Private Sub Labor_hours_LostFocus()
Dim varBookmark As Variant
varBookmark = Me.Bookmark
DoCmd.SetWarnings False
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Select Case Me.[Record Type]
Case 3
DoCmd.OpenQuery "Update Task Record-Template", , acEdit
DoCmd.OpenQuery "Delete calc record", , acEdit
DoCmd.OpenQuery "calculate template tasks 2-category", , acEdit
DoCmd.OpenQuery "Update Category Record-template", , acEdit
DoCmd.OpenQuery "Delete calc record", , acEdit
DoCmd.OpenQuery "calculate template tasks 2-phase", , acEdit
DoCmd.OpenQuery "Update Phase Record-template", , acEdit
Me.Requery
Me.Bookmark = varBookmark
If Forms![main switchboard]![Form Status] = True Then
DoCmd.GoToControl "Labor UM" 'GOTO THE NEXT FIELD
Else
Forms![main switchboard]![Form Status].Value = True
End If
Case Else
'do nothing
End Select
End Sub
Thanks Much!
3 9425
Hi All,
This is really basic but I'm having trouble finding a straight forward way to do this. I have an Access application where the for is in spreadsheet mode. When a user leaves a control there is a series of calculations and the parent and child forms are refreshed. The cursor goes back up to the first control in the first record after refreshed and I bring it back to the original record using a bookmark.
My problem is that I need to determine where to put the cursor depending on the keystroke pressed. For example, if the user presses the down arrow key, I want the key to go to a certain control. If the user presses the tab key I want it to go to the next control in the record.
Can anyone help. Here is an example of the current code where I need to build this in. - Private Sub Labor_hours_LostFocus()
-
-
Dim varBookmark As Variant
-
-
varBookmark = Me.Bookmark
-
-
DoCmd.SetWarnings False
-
-
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
-
-
Select Case Me.[Record Type]
-
-
Case 3
-
DoCmd.OpenQuery "Update Task Record-Template", , acEdit
-
DoCmd.OpenQuery "Delete calc record", , acEdit
-
DoCmd.OpenQuery "calculate template tasks 2-category", , acEdit
-
DoCmd.OpenQuery "Update Category Record-template", , acEdit
-
-
DoCmd.OpenQuery "Delete calc record", , acEdit
-
DoCmd.OpenQuery "calculate template tasks 2-phase", , acEdit
-
DoCmd.OpenQuery "Update Phase Record-template", , acEdit
-
-
-
Me.Requery
-
-
Me.Bookmark = varBookmark
-
-
If Forms![main switchboard]![Form Status] = True Then
-
DoCmd.GoToControl "Labor UM" 'GOTO THE NEXT FIELD
-
Else
-
Forms![main switchboard]![Form Status].Value = True
-
End If
-
-
Case Else
-
'do nothing
-
-
-
End Select
-
-
End Sub
Thanks Much!
It will probably be more visual than basic by the time you get done :-) Here's a link to a thread with a similar question: http://www.thescripts.com/forum/thread704885.html
The constants that you will need to use are: vbKeyTab for the tab key, and 40 for the down arrow key... Here's another posting with some additional information: http://www.thescripts.com/forum/thread658216.html
Regards,
Scott
Hi All,
This is really basic but I'm having trouble finding a straight forward way to do this. I have an Access application where the for is in spreadsheet mode. When a user leaves a control there is a series of calculations and the parent and child forms are refreshed. The cursor goes back up to the first control in the first record after refreshed and I bring it back to the original record using a bookmark.
My problem is that I need to determine where to put the cursor depending on the keystroke pressed. For example, if the user presses the down arrow key, I want the key to go to a certain control. If the user presses the tab key I want it to go to the next control in the record.
Can anyone help. Here is an example of the current code where I need to build this in.
Private Sub Labor_hours_LostFocus()
Dim varBookmark As Variant
varBookmark = Me.Bookmark
DoCmd.SetWarnings False
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Select Case Me.[Record Type]
Case 3
DoCmd.OpenQuery "Update Task Record-Template", , acEdit
DoCmd.OpenQuery "Delete calc record", , acEdit
DoCmd.OpenQuery "calculate template tasks 2-category", , acEdit
DoCmd.OpenQuery "Update Category Record-template", , acEdit
DoCmd.OpenQuery "Delete calc record", , acEdit
DoCmd.OpenQuery "calculate template tasks 2-phase", , acEdit
DoCmd.OpenQuery "Update Phase Record-template", , acEdit
Me.Requery
Me.Bookmark = varBookmark
If Forms![main switchboard]![Form Status] = True Then
DoCmd.GoToControl "Labor UM" 'GOTO THE NEXT FIELD
Else
Forms![main switchboard]![Form Status].Value = True
End If
Case Else
'do nothing
End Select
End Sub
Thanks Much!
To accomplish what you are requesting, you must capture the User's Keystrokes at the Form Level. To do this:- Set the KeyPreview Property of the Form to Yes.
- Place similar code in the Form's KeyDown() Event. The sample code snippet will capture most of the Navigation Keys:
- Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
-
Const vbKeyEnter = 13
-
-
Select Case KeyCode
-
Case vbKeyHome
-
'Home Key presseed
-
Case vbKeyEnd
-
'End Key pressed
-
Case vbKeyPageUp
-
'etc.
-
Case vbKeyPageDown
-
'etc.
-
Case vbKeyUp
-
'etc.
-
Case vbKeyDown
-
'etc.
-
Case vbKeyLeft
-
'etc.
-
Case vbKeyRight
-
'etc.
-
Case vbKeyTab
-
'etc.
-
Case vbKeyEnter
-
'etc.
-
End Select
-
End Sub
I have just been directed to work on another part of the program first so I won't get to this for a couple of days but it looks like this code is exactly what I'm looking for. I will respond as to how it works then. This is a tremendous help and this forum is a great resource!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Anita C |
last post by:
Hi,
How cookies can be used to set and then determine the last page visited by a
person browsing a particular website ? Also the page last visited is loaded
in an iframe, so the page last visited...
|
by: hoenes1 |
last post by:
How can I determine whether a download has been cancelled by the
client? I'm sending the file from an aspx page in chunks of 4K. When
the user presses "Cancel" in his download dialog, the next call...
|
by: Bill |
last post by:
Hello,
Could anyone post some simple code or advise me on how I can display the SSN
number like *****7890 in a text box, even thought the user entered
1234567890, and the value of the variable...
|
by: jeremiah johnson |
last post by:
Hi all.
I'm writing a small utility that can move a window from one of my
monitors to the other, when a system hotkey is pressed. I want to keep
the windowstate (maximized or normal) when the...
|
by: rdemyan via AccessMonster.com |
last post by:
Anyone have any ideas on how to determine when the back-end file (containing
only tables) has been updated with new data.
The date/time of the file won't work because it gets updated to the...
|
by: =?Utf-8?B?cGFucGF3ZWw=?= |
last post by:
Is there a way to quickly determine if the key pressed was from 'A'-'Z' or
'0'-'9' range?
I really don't like to write switch with every Keys.A, Keys.B, etc key listed
Paul
|
by: Johannes Meng |
last post by:
Good day,
I'm experimenting with unbuffered input at the moment. To get input I
basically use cin.get(). My problem are control sequences preceeded by an
ESC character (i.e. up, down, f-keys et...
|
by: JWest46088 |
last post by:
I'm trying to figure out how to read if a key was pressed by the user. For example, a line from a file is displayed and the user is prompted to hit any key to see the next line in the file. I've...
|
by: AdamOnAccess |
last post by:
I'm in Access 2007. I built a feature that to saves the current list in a sub form to a separate table. It works like this: After entering a list of words in the subform, the user can choose to push...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |