Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Sep 2002
    Posts
    81
    Thanks
    0
    Thanked 0 Times in 0 Posts

    one button to open and close form (Access 2000)

    Close form with double click ?

    I have a button for opening a popup form in the OnClick event. Can i use the same button to close it? I tried to close the form with the DoubleClick event but it doesnt work. I could use two buttons but it will be better to use the same button for the closing event.
    I will be gratefl for any advice

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

    Re: one button to open and close form (Access 2000)

    You don't need double click for that. You can check in the On Click event whether the form is loaded. If so, close it, otherwise open it:

    Private Sub cmdToggleForm_Click()
    Const strFormName = "frmPopup"
    If CurrentProject.AllForms(strFormName).IsLoaded Then
    DoCmd.Close acForm, strFormName, acSaveNo
    Me.cmdPopup.Caption = "Open popup form"
    Else
    DoCmd.OpenForm strFormName
    Me.cmdPopup.Caption = "Close popup form"
    End If
    End Sub

    Replace cmdToggleForm with the name of the command button, and frmPopup with the name of the popup form.

Posting Permissions

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