Trigger event by writing value to a field

Bieke

Member
Local time
Today, 17:35
Joined
Nov 24, 2017
Messages
72
Hello,

When i manualy change the value of a field in a form then the event 'afterupdate' of that field will be triggered.
What i want to do is write a value to that field using vba (so not by typing in to the field)
When the value changes by writing to that field then i want to run a function.
How do i do it ....?

Thanks in advance,

Bieke
 
How do i call it?
There must be an event triggered when the value changes in the controlfield, then i can execute a function in this event but how do i trigger it?
 
You might be able to implement this with a Data Macro on the table.

Data Macros run regardless of where or how a value is changed in a field.
 
When the value changes by writing to that field then i want to run a function.
How do i do it ....?
Control level events do not fire when you change controls via code. Period. You can manually call some of them but I don't recommend that. If you have code in an event procedure that you need to run from multiple places, move the code out of the event procedure and into a standard Sub. Then call that sub from the event procedure and the procedure that modifies the control via code.

If we are talking about validation code, move the validation code to the form's BeforeUpdate event. That always runs before the record is saved.

Here is a link to a database that will help you to understand when events fire. You might want to watch one of the videos first to see how the form works.

 
What i want to do is write a value to that field using vba
If you use VBA in such a targeted manner, you can also call the desired function. You don't need an extra event for this.
However, you would have to check separately before calling the function whether the content of the control really changes when it is overwritten using VBA. This raises the question of what exactly this VBA write action looks like in order to make a modification.

run a function
Of course, one could also take a closer look at what exactly this function is supposed to do.
 
Last edited:
Already suggested in the crosspost
 

Users who are viewing this thread

Back
Top Bottom