Access 2016 error message Sub Or Function not defined

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LAAllen
    New Member
    • Jan 2018
    • 1

    Access 2016 error message Sub Or Function not defined

    If IsLoaded("ViewA ctivities Form") Then DoCmd.Requery acForm, ([ViewActivities Form])
    this gives me the error: Sub or Function not defined
    WHY?
  • PhilOfWalton
    Recognized Expert Top Contributor
    • Mar 2016
    • 1430

    #2
    Have you defined the IsLoaded function?

    The built in IsLoaded works like this
    Code:
       CurrentProject.AllForms("ViewActivities Form").IsLoaded
    I also use this user function (before the above function existed)
    Code:
    Function IsLoaded(ByVal strFormName As String) As Integer
     ' Returns True if the specified form is open in Form view or Datasheet view.
        
        Const conObjStateClosed = 0
        Const conDesignView = 0
        
        If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
            If Forms(strFormName).CurrentView <> conDesignView Then
                IsLoaded = True
            End If
        End If
        
    End Function
    Phil

    Comment

    Working...