How to closing forms

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

Guest

I've created several forms/queries which are accessed via command buttons.

So that I don't end-up with several forms open simultaneously, how do I
close the form that included the command button if it's no longer needed
after the new form is open?

I've looked at the logic in the Docmd.Close function and thought about
trying to incorporate that in the logic for the "Open Form" button, but have
no idea how to do that or it it's the way this should be done.

Thanks for your help.
 
Hi, Sorsche.
So that I don't end-up with several forms open simultaneously, how do I
close the form that included the command button if it's no longer needed
after the new form is open?

Use the DoCmd.Close method to close the current form. For example, try:

Private Sub OpenAssetsBtn_Click()

On Error GoTo ErrHandler

DoCmd.OpenForm "frmAssets"
DoCmd.Close acForm, Me.Name

Exit Sub

ErrHandler:

MsgBox "Error in OpenAssetsBtn_Click( ) in " & Me.Name & " form." & _
vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.Description
Err.Clear

End Sub

.... where the button is named OpenAssetsBtn, and the other form is named
frmAssets.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
Back
Top