Results 1 to 4 of 4
  1. #1
    Join Date
    May 2007
    Posts
    31

    Unanswered: command button not functioning

    I've created a form that contains a command button which has the following code assigned on the on click event...

    Private Sub btnCloseform_Click()


    DoCmd.Close

    End Sub


    When I click the button it does NOTHING -

    any suggestions?

    Thanks.

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Sometimes Access hiccups and forgets to go looking for event procedures.
    Try "re-linking" your event by right clicking the command button in design view and clicking "Build Event...".
    This should take you to the above code.

    Then try click the turd again
    George
    Home | Blog

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Also be warned that if you're using DoCmd.Close to close a form that's used for data entry/editing, it will close the form, dumping the current record if it is unsaved and fails a validation test, and give you no warning of this fact!

    In this circumstance, to force Access to run the validation testing use this code:

    If Me.Dirty Then Me.Dirty = False
    DoCmd.Close

    The bad thing about this is that DoCmd.Close is the code the button wizard generates for this purpose!

    The above code should not be used to close an unbound form, such as a "menu" or "switcboard" form. Since they have no Record Sources, they have no Dirty property and this will throw an error. I've been told that the ACC2007 Command Button Wizard automatically adds the If Me.Dirty Then Me.Dirty = False code, so users of this version beware whengenerating a close button for this purpose.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Join Date
    May 2007
    Posts
    31
    Thanks for responding....

    It appears that a control "earlier" in the form has some issue which is corrupt ing the form.

    Just a wee frustrating but as Missingling says there is more than one way to skin a cat!

    Thanks again!

Posting Permissions

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