Passing Access Parameters into Custom Function

  • Thread starter Thread starter Scott
  • Start date Start date
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
 
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)
 
Back
Top