Causing an event

User avatar
silverback
5StarLounger
Posts: 776
Joined: 29 Jan 2010, 13:30

Causing an event

Post by silverback »

I have a form which contains a Salary field. The user has two ways of completing salary; they can type one in or get one put in automatically by selecting a Pay Point. Whichever method is used, there's a requirement to calculate the hourly rate.
For the typing in option, there's an update event; this triggers OK and all works fine.

For the automatic method, the salary is retrieved from a simple look up table using DLookup and the value written into the Salary field. This does not trigger the update event, so hourly rate is not calculated. I tried putting a Dirty event on the salary field, but this doesn't seem to work either.

Am I doing something wrong in processing the dirty event or what do I need to do to trigger and event when the VB writes into the salary field.
Thanks
Silverback

User avatar
HansV
Administrator
Posts: 78524
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Causing an event

Post by HansV »

The After Update event only occurs if the user enters/edits a value, not when the value is changed from code.

You can call the After Update event of the Salary field from the After Update event of the Pay Point control, after setting the value of the Salary field. It'd look similar to the following (which is air code, of course):

Code: Select all

Private Sub PayPoint_AfterUpdate()
  Me.Salary = DLookup(...)
  Call Salary_AfterUpdate
End Sub
Best wishes,
Hans

User avatar
silverback
5StarLounger
Posts: 776
Joined: 29 Jan 2010, 13:30

Re: Causing an event

Post by silverback »

Calling a subroutine that already exists. Wow, who'd have thought of that?
Not me, obviously!

Many thanks
Silverback