Results 1 to 4 of 4
  1. #1
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875

    Change FieldB When FieldA Changed FROM DefaultValue

    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;).

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    One way that comes to mind would be to have a form level Boolean variable. Set it to False in the load event. When the first combo changes, test that variable. If it's False, change the second combo and set it to True. If the first combo changes again, the variable will be True so the second won't be changed.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Seriously?

    I ask a real, complex question and get "use a Form variable" as the answer??!?

    . . .

    You, sir, are a genius (You are. Really)

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'm lazy and simple-minded; complex solutions are hard for me.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. keeping current entry in field until changed
    By Chazcoral in forum Forms
    Replies: 16
    Last Post: 09-09-2010, 12:01 PM
  2. Replies: 2
    Last Post: 11-04-2009, 09:45 PM
  3. Replies: 7
    Last Post: 05-29-2009, 04:27 PM
  4. Find out changed data
    By Papote in forum Programming
    Replies: 1
    Last Post: 04-27-2009, 08:19 PM
  5. Replies: 4
    Last Post: 04-01-2009, 11:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums