• Form/Subform and record actions (Access 97)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Form/Subform and record actions (Access 97)

    Author
    Topic
    #361990

    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 smile

    Viewing 0 reply threads
    Author
    Replies
    • #548776

      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

      Private Sub cmdUndoChanges_Click()
      me.undo
      End Sub

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

      Private Sub cmdUndoChanges_Click()
      me.subformname.form.undo
      End Sub

      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

      • #548778

        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 smile

        • #548779

          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… smile , sometimes it’s just easier???) smile

          Jayden

        • #548780

          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.

          • #548786

            Thanks Charlotte.

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

            • #548895

              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. shrug

    Viewing 0 reply threads
    Reply To: Form/Subform and record actions (Access 97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: