Results 1 to 6 of 6
  1. #1
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328

    Prevent form updates for certain conditions.


    Using a2003 and a 2007. The title for this is weird since I couldn't think of how to summarize. I have a single form with quite a few combo boxes and some buttons. If certain conditions exist and the user tries to make a change, I want the user to get a message that warns him that this item is already ordered. If he has made a mistake by making a change, he can click the undo button on the message box. If he still wants to make a change, he clicks continue and code turns off the warning and allows updates.

    For fields on the form, I can use ondirty or keyPress to sense that someone is trying to make a change. For combo boxes, I would like to present the same message when the user tries to use any combo box. Do I have to put code in for each box or is there some way that I can initiate an event if he tries to use any of the boxes?

    Any help much appreciated.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Code for each combobox unless you want every keystroke or click on the form to trigger code.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    Looks like no easy out-I will play with it some more. I was thinking that, after the first rejection and then a decision to carry on, I could set an unbound control to some value that would then allow free changes.

    Thanks for quick replay. This site and its quick access to experienced people is wonderful.

  4. #4
    Xipooo's Avatar
    Xipooo is offline Sr. Database Developer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Arizona
    Posts
    332
    Assuming you are using a bound form, the Before Update event is where you can verify what the user selects, then if you want to prevent that value from being updated you set Cancel = True and that will cancel the update of the underlying data.

  5. #5
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    Quote Originally Posted by Xipooo View Post
    Assuming you are using a bound form, the Before Update event is where you can verify what the user selects, then if you want to prevent that value from being updated you set Cancel = True and that will cancel the update of the underlying data.
    The before update doesn't fire until after all the changes have been made, when go to next record etc. I was wanting something that generated a message as soon as tried to make first change in any field or pull down. OnDirty seems to be the closest. One problem for me with onDirty is that it only acts the first time you use it. I have tried setting
    Ondirty
    Do something with code
    me.dirty=false (so will fire again if try to something else on same record.)
    This somehow doesn't make the form clean.

    Thanks for taking time for this.

  6. #6
    Xipooo's Avatar
    Xipooo is offline Sr. Database Developer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Arizona
    Posts
    332
    You would have to set the On Update for every field in your form. There isn't any event currently that fires when any value is changed except for the "On Dirty".

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

Similar Threads

  1. Replies: 6
    Last Post: 11-30-2013, 02:41 PM
  2. Conditions In Form
    By drunkenneo in forum Forms
    Replies: 1
    Last Post: 06-21-2013, 02:15 PM
  3. Form Field value updates
    By l2extasy in forum Forms
    Replies: 2
    Last Post: 07-10-2012, 09:21 AM
  4. Combo Box on form updates unintentionally
    By zipmaster07 in forum Forms
    Replies: 2
    Last Post: 03-06-2012, 10:21 PM
  5. Tracking Log of updates in a form
    By cin324 in forum Access
    Replies: 9
    Last Post: 11-30-2011, 01:12 PM

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