G
Gordon
I have a datasheet that gets returned from a query. I can set its properties
such as allowedits, allowinsert etc. by using screen.activedataset.allowedits
= true.
I need to control what happens for the keydown event for this
activedatasheet but don't quite understand structure and syntax to do this.
Normaly for a form, you can statically set the code that will run when the
form's event triggers, such as keydown. I need to be able to dynamically
program what will happen when the keydown event happens.
for example, on a form I can have the following:
--------------------------------------------
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Call mForm_KeyDown(KeyCode, Shift)
End Sub
---------------------------------------------
Public Sub CheckKeydDwn(ByVal KeyCode As Integer, ByVal Shift As Integer)
Dim bShiftDown As Integer, bAltDown As Integer, bCtrlDown As Integer
Dim intCtrl As Integer
' Trap the keystroke combinations
' The form's KeyPreview property must be True
bShiftDown = (Shift And acShiftMask) > 0 'Test for Shift Key
bAltDown = (Shift And acAltMask) > 0 'Test for Alt key
bCtrlDown = (Shift And acCtrlMask) > 0 'Test for Ctrl key
If bCtrlDown And KeyCode = vbKeyH Then ' Ctrl+H pressed
KeyCode = 0 ' Throw out the keystrokes
MsgBox ("Ctrl-H not allowed")
End If
If bCtrlDown And KeyCode = vbKeyP Then 'Ctrl+P pressed
KeyCode = 0 'throw out keystrokes
MsgBox ("Ctrl-P not allowed")
End If
If bCtrlDown And KeyCode = vbKeyC Then 'Ctrl+C pressed
KeyCode = 0 'throw out keystroke
MsgBox ("Ctrl-C not allowed")
End If
If bCtrlDown And KeyCode = vbKeyF12 Then
KeyCode = 0 'throw out keystroke
MsgBox ("F12 not allowed")
End If
End Sub
-------------------------------------------
How can I programattically set this for a datasheet
I tried
Screen.ActiveDatasheet.OnKeyDown = "=CheckKeyDown(byval keycode as
integer,byval shift as integer)"
but that doesn't work.
Any suggestions?
Thanks
Gordon
such as allowedits, allowinsert etc. by using screen.activedataset.allowedits
= true.
I need to control what happens for the keydown event for this
activedatasheet but don't quite understand structure and syntax to do this.
Normaly for a form, you can statically set the code that will run when the
form's event triggers, such as keydown. I need to be able to dynamically
program what will happen when the keydown event happens.
for example, on a form I can have the following:
--------------------------------------------
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Call mForm_KeyDown(KeyCode, Shift)
End Sub
---------------------------------------------
Public Sub CheckKeydDwn(ByVal KeyCode As Integer, ByVal Shift As Integer)
Dim bShiftDown As Integer, bAltDown As Integer, bCtrlDown As Integer
Dim intCtrl As Integer
' Trap the keystroke combinations
' The form's KeyPreview property must be True
bShiftDown = (Shift And acShiftMask) > 0 'Test for Shift Key
bAltDown = (Shift And acAltMask) > 0 'Test for Alt key
bCtrlDown = (Shift And acCtrlMask) > 0 'Test for Ctrl key
If bCtrlDown And KeyCode = vbKeyH Then ' Ctrl+H pressed
KeyCode = 0 ' Throw out the keystrokes
MsgBox ("Ctrl-H not allowed")
End If
If bCtrlDown And KeyCode = vbKeyP Then 'Ctrl+P pressed
KeyCode = 0 'throw out keystrokes
MsgBox ("Ctrl-P not allowed")
End If
If bCtrlDown And KeyCode = vbKeyC Then 'Ctrl+C pressed
KeyCode = 0 'throw out keystroke
MsgBox ("Ctrl-C not allowed")
End If
If bCtrlDown And KeyCode = vbKeyF12 Then
KeyCode = 0 'throw out keystroke
MsgBox ("F12 not allowed")
End If
End Sub
-------------------------------------------
How can I programattically set this for a datasheet
I tried
Screen.ActiveDatasheet.OnKeyDown = "=CheckKeyDown(byval keycode as
integer,byval shift as integer)"
but that doesn't work.
Any suggestions?
Thanks
Gordon