change date field/control using a button (1 Viewer)

viennese_finger

New member
Local time
Today, 13:17
Joined
Nov 21, 2016
Messages
9
Hi - I have a form with a DateModified field/control. This field records the date an event occurs; this also causes a phase change in the main process.

The DateModified control is blank by default until this event occurs.

I am using a button ("Date modified"; on-click event; code builder; DateModified = Date) to enter today's date into the DateModified field - this works fine - the button is clicked and today's date is entered into the DateModified box.

However, I would also like a to register this change in the process or event in another field (combo box = cboPhase)

The code for this: If DateModified > 0 Then

cboPhase = 8

End If


So in design view for form, under 'property sheet' and 'event' on the DateModified field, and tried putting the above code into vairous events (afterUpdate, BeforeUpdate, On Dirty, On Change etc.) but none of them will change the value in the combo box field. Most of these options will record a 'manual' change in the DateModified field, e.g. if I change or update the date itself, the Phase value changes to 8, so I know that the code works; it's just getting it to update the cboPhase value once the date is changed by using the button.

Hope this makes sense, and that someone can understand what I'm trying to do!

Cheers,
Matt
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 05:17
Joined
Aug 30, 2003
Messages
36,125
You'd want that behind the button, not in any event related to the date field.
 

Minty

AWF VIP
Local time
Today, 13:17
Joined
Jul 26, 2013
Messages
10,371
Just to add a little on what Paul has said, you should be aware that field / control value changes made in code do NOT trigger any of that controls events.

So you setting the date via your button code would not trigger that controls after update event.
 

viennese_finger

New member
Local time
Today, 13:17
Joined
Nov 21, 2016
Messages
9
Ok, pbaldy and Minty - it makes sense - I will go with that

Thanks a lot for your help

Matt
 

Users who are viewing this thread

Top Bottom