Results 1 to 8 of 8
  1. #1
    plavookins is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2011
    Posts
    6

    Compile error. Sub of function not defined


    I created report and add code (see picture) on event ON OPEN to open form to supply parameter to report but I got this error.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Have you used this "IsLoaded" function before?

  3. #3
    plavookins is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2011
    Posts
    6
    No, never. I copied this code from some microsoft links...

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You need to copy the code for the function as well. If you can't find it I believe I have it somewhere.

  5. #5
    plavookins is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2011
    Posts
    6
    Found the problem. I need to create a new module to declare variable bInReportOpenEvent (using a Dim statement)

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    This function belongs in a Standard Module:
    Code:
    Public Function IsLoaded(ByVal strFormName As String) As Boolean
    '-- 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

  7. #7
    plavookins is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2011
    Posts
    6
    Thanks RuralGuy for your help

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Are you ready to use the Thread Tools and mark this thread as Solved?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 02-22-2011, 06:10 AM
  2. new compile error!
    By darklite in forum Access
    Replies: 6
    Last Post: 09-02-2010, 05:13 PM
  3. Replies: 3
    Last Post: 08-24-2010, 09:26 AM
  4. Error: "User-defined type not defined"
    By mastromb in forum Programming
    Replies: 10
    Last Post: 01-08-2010, 02:57 PM
  5. Replies: 23
    Last Post: 03-26-2009, 06:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums