Results 1 to 7 of 7
  1. #1
    EddieN1 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    316

    How to Enable Button in Main Form when Subform is Dirty

    I have a Main Form (Single Form View) and a Subform (Continuous Form View) with a Command Button on the Main Form. In the Subform, I have set default values in the detail so that when a new line appears, the form is immediately Dirty. In this state, the command button in the Main Form is disabled. If the user hits ESC, then the Dirty symbol (pencil) on the left goes away and the command button is enabled. However, I want to enable the command button without the user hitting ESC. Any way to do this? Thanks, Eddie

  2. #2
    EddieN1 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    316
    Well, I think I found this myself. In the On Current event of the Subform, I added...

    If Me.Dirty then
    Me.Undo
    End If

    Anything I might be overlooking? Thanks, Eddie

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I would probably lean towards saving the record.

    If Me.Dirty then
    me.dirty = false
    End If

  4. #4
    EddieN1 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    316
    ItsMe, the part I didn't emphasize is that if the record is Dirty when the On Current event triggers, then it is a NewRecord and hasn't been filled out yet. I don't want to save it unless something else changes in it. Thanks for your comment.

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I fail to see the logic of using .Dirty or .Undo in the On Current event. You mentioned it provides a desired result. Not sure how the form is doing this. You know the function of the form better than I. Of all the actions to take in an on current event, an Undo seems to be the least desirable. If, in fact, you can take such an action I would try to avoid it.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    To add to ItsMe's observations, if in fact you are using the Default properties of either the controls on the form or the field property sheet, they will not Dirty a record. If in fact your record is getting Dirty then you are probably doing something else to the record. Just my $0.02.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    I agree, record is not initiated just because of DefaultValue property. Something else is happening.
    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.

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

Similar Threads

  1. Replies: 6
    Last Post: 05-18-2013, 12:48 AM
  2. Replies: 2
    Last Post: 06-26-2012, 10:54 PM
  3. Call a button on the main form from the subform
    By Grooz13 in forum Programming
    Replies: 1
    Last Post: 09-28-2011, 01:15 PM
  4. Enable button in the master form when clicking in the detail
    By DistillingAccess in forum Programming
    Replies: 8
    Last Post: 08-03-2010, 10:54 AM
  5. Replies: 0
    Last Post: 07-26-2010, 04:36 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