Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

module code to close a form does not work

Discussion in 'Information Technology' started by Angus Comber, Jul 28, 2006.

  1. Angus Comber

    Angus Comber
    Expand Collapse
    Guest

    Hello

    I have a form called NewPolicy. On this form is a button which calls some
    VBA code. At the end of the code is the line:

    DoCmd.Close acForm, [Forms]![NewPolicy], acSaveNo

    But this line does not close the form! What am I doing wrong?

    Angus
     
  2. Loading...

    Similar Threads Forum Date
    Introducing The Spn Code Of Forum Etiquette Announcements Feb 20, 2016
    UK Sikh 'code of silence' on sexual grooming Breaking News Sep 2, 2013
    Can a Dress Code Bar Ethnic and Religious Attire Based on Customer Preferences in the US? Questions and Answers May 3, 2011
    Pacific Code Exempts Religious Drivers (Fiji) Breaking News Feb 16, 2011
    Controversial Gurdwaras 'Breaking the Sikh Code' on Meat and Alcohol Hard Talk Dec 2, 2010

  3. Douglas J. Steele

    Douglas J. Steele
    Expand Collapse
    Guest

    The Close method is looking for the name of the object to close, not a
    reference to it.

    Try:

    DoCmd.Close acForm, "NewPolicy", acSaveNo


    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no private e-mails, please)


    "Angus Comber" <nospam@gmail.com> wrote in message
    news:eHqaLGgpGHA.2400@TK2MSFTNGP03.phx.gbl...
    > Hello
    >
    > I have a form called NewPolicy. On this form is a button which calls some
    > VBA code. At the end of the code is the line:
    >
    > DoCmd.Close acForm, [Forms]![NewPolicy], acSaveNo
    >
    > But this line does not close the form! What am I doing wrong?
    >
    > Angus
    >
    >
     
  4. John Vinson

    John Vinson
    Expand Collapse
    Guest

    On Wed, 12 Jul 2006 23:21:10 +0100, "Angus Comber" <nospam@gmail.com>
    wrote:

    >Hello
    >
    >I have a form called NewPolicy. On this form is a button which calls some
    >VBA code. At the end of the code is the line:
    >
    >DoCmd.Close acForm, [Forms]![NewPolicy], acSaveNo
    >
    >But this line does not close the form! What am I doing wrong?
    >
    >Angus
    >


    You're not passing the *name of the form as a text string* in the
    second argument of the Close event - you're passing the Form as an
    object.

    Use either

    DoCmd.Close acForm, "NewPolicy", acSaveNo

    or (more flexibly)

    DoCmd.Close acForm, Me.Name, acSaveNo


    John W. Vinson[MVP]
     

Share This Page