Automatically Close a Form

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

Guest

Hi everyone hope you can help. I have a main form with a command button to open a linked form. When I open the linked form I would like the main form to automatically close. Can anyone help. Thanking you in advance.
 
Put this into the Click event procedure of your command button.

It ensures any edits are written to the table, opens the other form, and
closes itself:

If Me.Dirty Then
Me.Dirty = False
End If
DoCmd.Open "MyOtherForm"
DoCmd.Close acForm, Me.Name

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Kez said:
Hi everyone hope you can help. I have a main form with a command button
to open a linked form. When I open the linked form I would like the main
form to automatically close. Can anyone help. Thanking you in advance.
 
Hi,
I have the same question, but don't understand the answer.
I am complete beginner so please type exactly what I should input

My first form is called "Name Input" (this is the form I want to
automatically close)
The form I want to open is called "Address Input"

Sorry to be a bit thick, but I hope you can help me also
 
Hi,
I have the same question, but don't understand the answer.
I am complete beginner so please type exactly what I should input

My first form is called "Name Input" (this is the form I want to
automatically close)
The form I want to open is called "Address Input"

Sorry to be a bit thick, but I hope you can help me also

Assuming "Name Input" is open... and cmdCloseThisOpenNext is the name
of the button on your "Name Input" form, this should work.

Private Sub cmdCloseThisOpenNext_Click()
On Error GoTo Err_cmdCloseThisOpenNext_Click

'--open the next form
DoCmd.OpenForm "Address Input", acNormal
'--Close the current form (Me.Name).
DoCmd.Close Me.Name, acForm, acSaveNo

Exit_cmdCloseThisOpenNext_Click:
Exit Sub

Err_cmdCloseThisOpenNext_Click:
MsgBox Err.Description
Resume Exit_cmdCloseThisOpenNext_Click

End Sub
 

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