• Command Buttons (Access 97 SR2)

    Author
    Topic
    #359428

    Just a simple question. I have a button on a form that when clicked opens a subform. The text on the button says “Open Subform”. I would like to have the text on the button read “Close Subform” after the subform opens. TIA

    Viewing 0 reply threads
    Author
    Replies
    • #538715

      Lonnie: Try this. Assume the name of the Command button is btnCommand.

      Private Sub btnCommand_Click()
      On Error GoTo btnCommand_Error

      If btnCommand.Caption = “Open Form” Then
      DoCmd.OpenForm (formname)
      btnCommand.Caption = “Close Form”
      Else
      DoCmd.Close
      btnCommand.Caption = “Open Form”
      End If

      Exit Sub

      btnCommand_Error:
      MsgBox Err.Description
      Exit Sub

      End Sub

      HTH.

      • #538752

        Thanks, Bill. I was able to do what I needed by using your example.

    Viewing 0 reply threads
    Reply To: Command Buttons (Access 97 SR2)

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

    Your information: