Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    Brookings, South Dakota, USA
    Posts
    449
    Thanks
    0
    Thanked 0 Times in 0 Posts

    subform Save & BeforeUpdate (Access 2002 (as 2k))

    Hi All,
    in the BeforeUpdate event of a subform I use different procedures for validation of data. One (If Me.Dirty Then...) is so the user cannot leave the subform without saving or undoing any data they have entered. My problem is that this gets in the way of the cmdSaveRecord button; it is pressed and the BeforeUpdate of the subform fires and asks if they wish to Save or Undo, press Save....etc, etc).
    How can I order within the events, or change my code, to allow the pressing of the Save Record button without this validation getting in the way?
    Thank You.

    gdr
    <IMG SRC=http://www.wopr.com/w3tuserpics/gdrezek_sig.jpg>
    "Those who dance are considered insane by those who can't hear the music" - George Carlin

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: subform Save & BeforeUpdate (Access 2002 (as 2k))

    I assume the cmdSaveRecord button is on the main form. By clicking this button, the subform loses focus. Access will save the current record in the subform automatically if the subform loses focus.

    To get around this, you might put a "Save Record" button on the subform.

    As an alternative, you might look into an example Microsoft provides of rolling back changes in a main form and subform. It is part of the Sample Forms database. You can download it from ACC2000: Microsoft Access 2000 Sample Forms Database Available in Download Center.

  3. #3
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    Brookings, South Dakota, USA
    Posts
    449
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: subform Save & BeforeUpdate (Access 2002 (as 2k))

    Hi Hans and Thanks,
    I'm sorry, actually, the BeforeUpdate and the cmdSaveRecord button are both on the subform. It's because of the losing focus that it is not on the MainForm. I'm looking over FrmSmp00.mdb and haven't really seen anything (probably 'cause it didn't jump out and bite me) that I can bend (or break) for what I'd like. I don't always have a 'keen eye for the obvious', so if you (or anyone else for that matter) have any other suggestions, I would certainly be happy to try them.
    Thanks again.

    gdr
    <IMG SRC=http://www.wopr.com/w3tuserpics/gdrezek_sig.jpg>
    "Those who dance are considered insane by those who can't hear the music" - George Carlin

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: subform Save & BeforeUpdate (Access 2002 (as 2k))

    You should be able to test screen.activecontrol to determine whether the cmdSave button was clicked and suppress the beforeupdate message if you wish. I'm not quite sure what the problem is, though. Do you NOT want to confirm the save if they click the save button?
    Charlotte

  5. #5
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    Brookings, South Dakota, USA
    Posts
    449
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: subform Save & BeforeUpdate (Access 2002 (as 2k))

    Hi Charlotte and Thank You,
    Yes, that's it. The Confirm Save MsgBox is not wanted and when they press Save, they expect it will and that it will not question their action. (One must give tenured faculty their due after all <img src=/S/bow.gif border=0 alt=bow width=15 height=15> ). <img src=/S/grin.gif border=0 alt=grin width=15 height=15> But I still needed to ensure that any unwanted or incomplete data was entered.
    Anyway, thanks for suggesting Screen.ActiveControl. I obviously hadn't thought about using that property and it works well.
    Thank you again.

    gdr
    <IMG SRC=http://www.wopr.com/w3tuserpics/gdrezek_sig.jpg>
    "Those who dance are considered insane by those who can't hear the music" - George Carlin

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: subform Save & BeforeUpdate (Access 2002 (as 2k))

    One other thing to keep in mind is that the BeforeUpdate event isn't triggered unless the record is dirty, and there's no point in "saving" a record that isn't. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15> In other words, there isn't any point in doing a test for me.dirty in BeforeUpdate.
    Charlotte

  7. #7
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    Brookings, South Dakota, USA
    Posts
    449
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: subform Save & BeforeUpdate (Access 2002 (as 2k))

    Hi Charlotte,
    Gotcha. Thank you very much for your help. <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>

    gdr
    <IMG SRC=http://www.wopr.com/w3tuserpics/gdrezek_sig.jpg>
    "Those who dance are considered insane by those who can't hear the music" - George Carlin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •