acCmdClose

Code Examples

Close Open Form

acCmdClose

This example accepts the name of a form and closes it if it is open.

' ****************** Code Start *********************
' Example by Terry Wickenden

Sub CloseOpenForm (strName as String)

  On Error Goto ErrClose

  DoCmd.SelectObject acForm, strName, False
  DoCmd.RunCommand acCmdClose
  Exit Sub

ErrClose:

  Select Case Err
    Case 2489
      'Form Not Open
    Case Else
      MsgBox Err & :-" & vbCrLf & Err.Desciption
  End Select

End Sub

' **************** Code End ******************

© 1998 - 2011 Terry Wickenden TKW Design Site developed maintained and hosted by TKW Design. This site is best viewed at 1024 x 768. Optimised for Firefox.