In short, I'm looking for a way to record the previous value of a Form Field when it's contents is changed.
I have a Form with two Combo Boxes and a Command Button.
The Combo Boxes are used to determine the start and end Dates used in a Report.
The Command Button opens the Report.
The Combo Boxes are each populated by the Query "SELECT DISTINCT DateValue([TDate]) FROM TemperData ORDER BY DateValue([TDate]) DESC;"
In the Form's On Load event, the "default values" for these two Combo Boxes are set to the first value in the above Query (the most recent date in the table).
What I'm wanting to do is update the Second Combo Box's selected date to match the first Combo Box's date, but ONLY when the first Combo box is changed FROM it's "default value" TO something else.
For example, I open the Form and both Combo Boxes display the following list:
Code:
7/8/2010
7/7/2010
7/6/2010
7/2/2010
7/1/2010
Both Combo Boxes have the value 7/8/2010 pre-entered in them (by the Form's On Load event - not by the field's DefaultValue property).
I When I change the first Combo Box from 7/8/2010 to (let's say) 7/6/2010, I want the second Combo Box to change to the same value.
However, if I change the first Combo Box AGAIN, changing it to 7/7/2010, I DON'T want the second Combo Box to change (so it stays at 7/6/2010).
What's the best way of doing this?
P.S.
I'm using the Form's On Load event to set the default values of the two Combo Boxes because it won't let me dynamically select the first item in the Row Source as the Default Value. It complains about combining TOP 1 with DISTINCT in the Query (SELECT TOP 1 DISTINCT DateValue([TDate]) FROM TemperData ORDER BY DateValue([TDate]) DESC;).