troubleshooting Question

Return variables using procedure/function in events in MS-Access

Avatar of rikacoma
rikacomaFlag for Netherlands asked on
Microsoft AccessVBA
5 Comments1 Solution34 ViewsLast Modified:
Normally if I want to do something with an event in a control on a form I use "[Event procedure]" and handle it in VBA. So somthing like Private Sub SomeControl_BeforeUpdate(Cancel As Integer) is handled in VBA and the Cancel variable is set there. The control then reacts to the new value of the cancel-variable. Works great.

Now I have a situation where a control is added dynamically on a form. I don't create any VBA but I do set (in design): SomeControl.OnBeforeUpdate = '=GeneralHandler()'

In that public call I then use screen.activecontrol to act on it.

But is it possible to give return values back? So if GeneralHandler() decides that the beforeUpdate should be cancelled, how do I  return this variable so that the controls acts in a normal behaviour.

It is not only an issue with BeforeUpdate. Even more with NotInList and all other events with return variables.

Suggestions how to do that?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros