Solved

Access Event Parameters From A Custom Function

Posted on 2008-10-23
4
299 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month8 days, 6 hours left to enroll

615 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