Avatar of Richard Badenhop
Richard Badenhop
Flag for Netherlands

asked on 

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

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?
Microsoft AccessVBA

Avatar of undefined
Last Comment
Fabrice Lambert

8/22/2022 - Mon