Solved

Access Event Parameters From A Custom Function

Posted on 2008-10-23
4
296 Views
Last Modified: 2013-11-27
Does anyone know a way to access the parameters exposed by an event in a custom function call?

For example, if you set the OnKeyDown event property for SomeField to [Event Procedure] then access creates the following in the Form's class module:

Private Sub SomeField_KeyDown(KeyCode As Integer, Shift As Integer)

End Sub

I would like to be able to set the OnKeyDown event property for SomeField to =MyKeyDownFunction() and then write a function like:

Public Function MyKeyDownFunction()
    Select Case KeyCode
    Case vbKeyUp
             'Do something
    End Select
End Function

I want to know if there is any way to get to these auto-generated parameters other than setting the event property to "[Event Procedure]".

Thanks.
0
Comment
Question by:mwolfe02
  • 2
4 Comments
 
LVL 8

Assisted Solution

by:fabriciofonseca
fabriciofonseca earned 100 total points
ID: 22787390
Declare a public variable and read its status.

See the attached example.

regards
DoubleClickShift.mdb
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 400 total points
ID: 22787415
I never seen a way to do that.  I've wanted to do that also - especially from the Form Error event.  AFAIK, those are not exposed elsewhere.

mx
0
 
LVL 6

Author Comment

by:mwolfe02
ID: 22788048
fabriciofonseca,

Clever, but you still have to write code in the form's module.  I am trying to avoid [Event Procedure] altogether.


mx,

You were one of the experts I was hoping might have the magic answer.  Form Error is actually the event I had in mind when I asked the question.  I'd love to be able to hide that mysterious 'No current record.' error that rears its ugly head when I start trying to do too much 'magic' on a form.

I'm a big fan of using generic functions in event properties and it irks me when I can't keep a form lightweight just because I need to act on the value of one of these event parameters.

Anyway, yours was the answer I was expecting, but certainly not the one I was hoping for.  I'll leave this question open a few days on the long shot chance that someone out there has figured out how to do this.
0
 
LVL 6

Author Closing Comment

by:mwolfe02
ID: 31509265
I'm giving mx the lion's share of the points because he answered the question most accurately, but I had to throw in something for fabriciofonseca for cleverness and originality.  Thanks to both of you for your help.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question