Passing Access Parameters into Custom Function

S

Scott

I'm trying to write a custom function using KeyPress.

The standard "Event Procedure" event subroutine for the
KeyPress event has a parameter that is passed into it,
KeyAscii.
----
Private Sub TransDate_KeyPress(KeyAscii As Integer)

End Sub
 
A

Allen Browne

You cannot place your custom function in the OnKeyPress property, since you
can get the KeyAscii value only from the event procedure.

Instead, set the property to
[Event Procedure]
and call your function from inside the event procedure, e.g.:
Private Sub TransDate_KeyPress(KeyAscii As Integer)
Call MyFunction(KeyAscii)
End Sub

Then set up your function to accept an integer:

Public Function MyFunction(WhatKeyValue As Integer)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top