tags:

views:

33

answers:

2

I need particular users the ability to lock a record on a form, but I don't need anything too serious such as setting different security settings.

Idea: I would like to be able to have a certain keydown combination (ex: ctrl+alt+M) to open a message box. (I'm trying to avoid making a small form because all I need returned is either yes, no, or cancel)

I have been looking around, but I'm not sure where to start with this one... Your feedback is always appreciated!

+1  A: 

Have you considered AutoKeys macro?

Perhaps you wish to make it form specific?

Remou
I did, but I don't know how to get the functionality I want. (I want to make it more complicated than just "F2") I've posted my code as an answer.
Eric D. Johnson
I have added a note.
Remou
Have you looked at the form's Key Preview property? If you open the form's property sheet and put the cursor in the property (it's on the Events tab) and hit F1 you'll get an explanation of how to use it.
David-W-Fenton
A: 

I did, but I don't know how to get the functionality I want. Here is the code so far (I want to make it more complicated than just "F2")

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
 Dim strPrompt As String
 Dim strBoxTitle As String
 Dim msgAnswer As Integer

If [Manager Lock] = False Then
    strPrompt = "Lock this record?"
Else
    strPrompt = "Unlock this record?"
End If

strBoxTitle = "Manager Lock"

 Select Case KeyCode
    Case vbKeyF2
        msgAnswer = MsgBox(strPrompt, vbOKCancel, strBoxTitle)
            If msgAnswer = 1 Then
                [Manager Lock] = Not [Manager Lock]
            End If
    Case Else
 End Select
End Sub
Eric D. Johnson