Open and Close Pop up form with one Command Button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to close a pop up form by clicking the same command button
that was used to open it?
 
Yes, on your commandbutton click event, chk to see if the pop up form is open
if (currentproject.allforms("formName").Isloaded) then
docmd.close acform, "formName", acSaveYes
 
Try this

Put this in the sub for the command button

Dim intX As Integer
Dim intCount As Integer
intCount = Forms.Count - 1
For intX = intCount To 0 Step -1
If Forms(intX).name = "myform" Then
DoCmd.Close acform,Forms(intX).name
Exit Sub
End if
Next
DoCmd.OpenForm "myform"

change myform to your forms name
 
Jeff said:
Yes, on your commandbutton click event, chk to see if the pop up form
is open if (currentproject.allforms("formName").Isloaded) then
docmd.close acform, "formName", acSaveYes

Good suggestion, but why "acSaveYes"? Do you really want to save design
changes to the form without prompting?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top