This routine accepts the name of the object to be hidden and the type of object as Form, Report, Table etc. It then hides that object.
'***************** Code Start ******************* 'This code was originally written by Terry Wickenden. 'It is not to be altered or distributed, 'except as part of an application. 'You are free to use it in any application, 'provided the copyright notice is left unchanged. Sub TestHide(strObjectName As String, strObjectType As String) Dim intType As Integer On Error GoTo errTestHide Select Case strObjectType Case "Form" intType = acForm Case "Macro" intType = acMacro Case "Module" intType = acModule Case "Query" intType = acQuery Case "Report" intType = acReport Case "Table" intType = acTable Case Else MsgBox "Invalid object type", vbCritical, "Hide Error" Exit Sub End Select DoCmd.SelectObject intType, strObjectName RunCommand acCmdWindowHide Exit Sub ErrTestHide: Select Case Err Case 2489 MsgBox strObjectName & " is not open and therefore can not be hidden." Case Else MsgBox Err.Number & ":- " & vbCrLf & Err.Description End Select End Sub '****************** Code End ********************
Return to Example List