Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Morecambe England, Lancashire, England
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Opening/Closing a form (Access 2000)

    Hi,

    I have a command button on a form that opens another form with about six print options on it. All the command button says is "open print menu". On the Print option form, the last buttons says "Close print menu".

    It all works well, but it would be a lot better if the command button would open the print menu on the first click, the words then change to "close print menu" and the next click closes it and the words go back to "Open print menu"

    I simply cannot see a way of doing this and would be very grateful for any help.

    Thanks for any help - I do quite a lot with Access and don't like to bother you experts unless I'm really stuck.

    Best Wishes

    Michael Peak

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Opening/Closing a form (Access 2000)

    You could use code like this in the On Click event of the button:

    Private Sub cmdPrintMenu_Click()
    If Me.cmdPrintMenu.Caption = "Open Print Menu" Then
    DoCmd.OpenForm "frmPrintMenu"
    Me.cmdPrintMenu.Caption = "Close Print Menu"
    Else
    DoCmd.Close acForm, "frmPrintMenu"
    Me.cmdPrintMenu.Caption = "Open Print Menu"
    End If
    End Sub

    Replace cmdPrintMenu and frmPrintMenu by the appropriate names.

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Opening/Closing a form (Access 2000)

    A command button has a caption property than can be checked and set in code, so you could have something like


    if me!cmdPrint.caption = "open print menu" then

    me!cmdPrint.caption= "close print menu"
    the other code you want to operate in this case.
    else
    me!cmdPrint.caption ="open print menu"
    the other code you want to operate in this case
    end if

    inside the onclick event of the button
    Regards
    John



  4. #4
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Morecambe England, Lancashire, England
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening/Closing a form (Access 2000)

    Guys,

    Thank you very much for your answers it's very much appreciated

    Michael

Posting Permissions

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