Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    San Francisco, California, USA
    Posts
    358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form/Subform and record actions (Access 97)

    Hey Everyone!

    Has anyone come across this? I have a form (frmContacts) and a subform (frmContactsSub). The main form is basically uneditable, but the subform is editable (I had to do this in order to have an outer join that allows editing of the outside side).

    I have an undo button on my main form with the following code:
    DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70

    Now all my edits are on the subform, but when I run the above code I get an error that the Undo command is not available. I'm assuming that's because it's not keeping track of changes on the subform, only the main form.

    Any ideas on how to get around this? (Aside from putting the button on the subform, which I would like to do but can't for design reasons.)

    TIA!

    Cecilia <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  2. #2
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Wellington, New Zealand
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form/Subform and record actions (Access 97)

    Hi

    Firstly I think the (main)problem lies in the fact that you have the button that you want to click on the main form. This is a problem, because as soon as the subform loses the focus (which it does for you to be able to click on the button) it will perform a 'save' of the record, promptly followed by your undo command. It will be undoing any 'unsaved' changes, but there are none (as you have just saved the changes to the record by clicking out of the sub form).

    Secondly, I would tend to use the undo method of the form (or subform) instead of using the docmd object.

    For example to undo changes in a form by clicking a button (not a subform) you would use

    <font color=6495ed>Private Sub cmdUndoChanges_Click()
    me.undo
    End Sub</font color=6495ed>

    If you wanted to reference a sub form from your main form you would use

    <font color=6495ed>Private Sub cmdUndoChanges_Click()
    me.subformname.form.undo
    End Sub</font color=6495ed>

    Of course, this second one won't work as you want it because of the 'save' that happens when you lose the focus from the sub form.

    Hopefully someone else knows a 'work-around'. At least hopefully I have helped you further clarify the problem.

    Cheers

    Jayden

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    San Francisco, California, USA
    Posts
    358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form/Subform and record actions (Access 97)

    Hi Jayden--

    Thanks for the insight. Yes, it helps because at least I know what the problem is.

    Now the question remains--Is there a workaround?

    C <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  4. #4
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Wellington, New Zealand
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form/Subform and record actions (Access 97)

    At the risk of sounding cheeky?

    How about putting the button to undo the subform on the subform? (I know you said you couldn't because of design changes, but hey... <img src=/S/smile.gif border=0 alt=smile width=15 height=15> , sometimes it's just easier???) <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    Jayden

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

    Re: Form/Subform and record actions (Access 97)

    Once a record is saved, which happens when you click the button on the subform since the subform loses focus then, there is no undo for it, although you could always delete the whole record. If you want to undo edits, you need to do it from the subform or else you need code to store each original value for each control in the subform when you enter the record so that you can repopulate those controls with the original values after a save in order to create an "undo" capability.
    Charlotte

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    San Francisco, California, USA
    Posts
    358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form/Subform and record actions (Access 97)

    Thanks Charlotte.

    I think I'm going to consider myself defeated and go redesign my form. Bummer.

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

    Re: Form/Subform and record actions (Access 97)

    It happens to all of us at times. After you bump your nose on these things often enough, you learn to do it another way. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    Charlotte

Posting Permissions

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