Results 1 to 3 of 3
  1. #1
    caddcop is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2011
    Location
    Upper Marlboro, Maryland, USA
    Posts
    57

    Detect When Two Related Fields are Dirty

    I have a form for entering Staff Names and what I am trying to do, is only enable the Save Record button once both a first and last name are entered.
    I created a Form_Dirty sub and in it, I was checking the value of the two text boxes. If both were not Null then I'd enable the save button. This however only works when both are not null and when they are initially being entered, only one is non-null when the OnDirty event is run.
    So I tried using the Dirty Event in each text box and having it call the Form_Dirty procedure. However, the second text box to be filled is still Null when its OnDirty event fires, so the buttons still do not enable.
    I tried using AfterUpdate instead of OnDirty, for the text boxes, but those events don't fire until the user has exited both text boxes.


    I was hoping for something that could detect that one text box was edited and that the other was in a state of being edited and at that point, enable the save Button.

  2. #2
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254

    caddcop -

    Have you tried the BeforeUpdate event as this will allow you to cancel the update when the conditions you need are not met?

    Secondly, what about adding a combo box to your form whose recordsource is the table or query that contains the staff names and when a selection is made the text boxes are both populated.

    All the best,


    Jim

  3. #3
    caddcop is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2011
    Location
    Upper Marlboro, Maryland, USA
    Posts
    57
    Since this is the form used to add new staff, there is no way to select users from a table.
    Anyway, I figured out my solution.
    For each of the two fields I created a Dirty procedure, where it tests to confirm that it is Dirty and the other field is not null. When that is true, it enables the Save button.
    Then, in the Form Dirty procedure I check that the two other fields are not null and enable the Save record button there. Finally, since I disable all form navigation button when a form is dirty, I also call my custom dirtyForm procedure that executes a number of things I want done to change the interface while a record is in an edited state.
    Just FYI, I also have a cleanForm module that I run when the form is no longer Dirty to restore all of the items that dirtyForm disables. This is run by the Form current module, save record button, the undo edit button and also by a Form Keypress module to detect the user pressing the esc key.

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

Similar Threads

  1. How do I detect new records.
    By jcollins in forum Programming
    Replies: 3
    Last Post: 03-17-2011, 03:48 PM
  2. Replies: 4
    Last Post: 01-20-2011, 10:05 PM
  3. Dirty
    By JEPEDEWE in forum Programming
    Replies: 1
    Last Post: 11-13-2010, 04:50 PM
  4. can anybody explain dirty event to me?
    By RedGoneWILD in forum Programming
    Replies: 3
    Last Post: 08-05-2010, 01:50 PM
  5. Detect if a row is deleted from a table in the database
    By Hameed Madwar in forum Programming
    Replies: 0
    Last Post: 01-08-2009, 07:31 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