Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Access Event Parameters From A Custom Function

Posted on 2008-10-23
4
Medium Priority
?
303 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 400 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 1600 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Suggested Courses

730 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