1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Action Canceled - Using AllowClose on Form and Sub Form - Access 2007

Discussion in 'Business Applications' started by inquiring, Jun 3, 2011.

Thread Status:
Not open for further replies.
  1. inquiring

    inquiring Thread Starter

    Jun 3, 2011

    I have a subform which on its own - works beautifully but fails under the mainform. I use a main form to select the record that the end user wants to update. Upon update event on main form, the sub form opens, presenting fields for possible updating. The Sub Form also present 2 buttons - Save & Close or Cancel and Close (Undo). When the main form opens, the code set AllowClose as False. When the sub form is opened as a result of the update on the mainform, the issue is the Close command /code gets canceled. (Error 2501). I have tried: 1. setting AllowClose (true and False) on both forms, 2. only the main form and 3. only the subform. None of these 3 configurations resolves the issue. Also, I tried moving the buttons to the mainform instead of the sub form but that failed as well.

    The application has a dozen forms and all of them utilize AllowClose functionality so the end user MUST use the buttons on the forms to force background queries (updates, deletes, perform calculations, recalc control totals etc). This is the first time I have tried to use Allow Close on a subform with buttons.

    XP and Access 2007


    Private AllowClose As Boolean

    Private Sub Form_Load()
    AllowClose = False
    End Sub

    Private Sub Form_Unload(Cancel As Integer)
    Cancel = Not AllowClose
    End Sub

    Private Sub SaveChangeandCloseForm_Click()
    AllowClose = True

    Private Sub CancelAddingNewRecord_Click()
    If Me.Dirty Then
    End If
    If Not Me.NewRecord Then
    End If
    AllowClose = True

    ANY suggestions are welcomed.

    Thank you
  2. Rockn


    Jul 29, 2001
    Why not just use a listbox to display the records based on the selection on the main form? I don't think you can actually close a sub-form on a main form since it is tied to the main form.
  3. OBP


    Mar 8, 2005
    Does the mainform/subform use the Master/Child Links?
    As they would control the displaying of the subform.
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Similar Threads - Action Canceled Using
  1. estyMonsty
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1000397

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice