Soft-coding Keypress Event Handler - How is it done?

dlindner999

New member
Local time
Yesterday, 18:52
Joined
Jun 17, 2014
Messages
2
Hi,
I newly entered the world of soft-coding event handlers, using this as my guide:
(www)access-programmers.co.uk/forums/showthread.php?t=166799

I have put this concept to use in my db for OnClick events and such, and I really like it so far. However, I am now trying to use it for a Keypress event, and getting errors. My guess is that the argument in the Keypress event is throwing it off. The keypress event has an argument, like so:

Code:
Private Sub txtResponseLetterA_Keypress(KeyAscii As Integer)
whereas OnClick events just have

Code:
Private Sub cmdRefA_Click()

So what do I need to do for a Keypress event to work, or is it possible at all?

I'm getting the following error:
Error 438: Object doesn't support this property or method.

Here's the line giving me the error:

Code:
Me(strRspLetter).KeyPress = MakeFunctionCall("HandleRspCheck", strRspLetter)

in the statement above, strRspLetter = "txtResponseLetterA"
 
I think you can just test the value of KeyAscii and use it to trigger an event
i.e.
Code:
If KeyAscii = 65 or KeyAscii = 97 'which is 'A' or 'a' key
    MakeFunctionCall
End If
 
Fixed - I just forgot that it's Me(strRspLetter).OnKeyPress, not
Me(strRspLetter).KeyPress
Thanks for the help!
 

Users who are viewing this thread

Back
Top Bottom