Solved

Error Message: Invalid Outside Procedure

Posted on 2003-11-08
8
620 Views
Last Modified: 2012-05-04
Using Access 2000. I am using the following two procedures. The first one is in the form's general declaration section, and the second one is in the Combo Box's Not In List property, which by the way has it's Limit To List property set to yes.

[First One]
Private Function IsLoaded(strName As String, _
 Optional lngType As AcObjectType = acForm) As Boolean
    IsLoaded = (SysCmd(acSysCmdGetObjectState, _
     lngType, strName) <> 0)
 End Function

[Second One]
Private Sub cboKeyCode_NotInList(NewData As String, Response As Integer)
    Dim mbrResponse As VbMsgBoxResult
    Dim strMsg As String
   
    strMsg = NewData & _
     " isn't an existing Key Code. " & _
     "Add a new Key Code?"
    mbrResponse = MsgBox(strMsg, _
     vbYes + vbQuestion, "Invalid Key Code")
    Select Case mbrResponse
        Case vbYes
            DoCmd.OpenForm "Key Code", _
                DataMode:=acFormAdd, _
                WindowMode:=acDialog, _
                OpenArgs:=NewData
               
                'Stop here and wait until the form goes away
                If IsLoaded("Key Code") Then
                    Response = acDataErrAdded
                    DoCmd.Close acForm, "Key Code"
                Else
                    Response = acDataErrContinue
                End If
        Case vbNo
            Response = acDataErrContinue
    End Select
End Sub

Here's the problem...When I attempt to enter a value into the Combo Box which is not in the list, I am getting the error message: Invalid Outside Procedure. What do I need to do to correct this procedure? Thanks in advance for your assistance.
0
Comment
Question by:CatDaddy2003
  • 4
  • 3
8 Comments
 
LVL 32

Expert Comment

by:jadedata
ID: 9707226
Hey CatDaddy2003!

  The procedures have no error trapping in them.  Insert error trap with a msgbox...

  Proc_Err:
    select case err
    case else
      msgbox "Error: " & err & " - " & Error$
      resume Proc_Exit
      resume
    end select

When the error occurs, activate the "resume" line (click on it and {CTRL}{F9})
Then {F8} will take you to the line that is causing the error..
 
regards
Jack
0
 

Author Comment

by:CatDaddy2003
ID: 9707308
OK, what I did was to add your procedure to the OnError propety of the form. This did not produce the anticipated results. Was I wrong? If so, where did I go wrong? Thanks in advance...
0
 
LVL 32

Expert Comment

by:jadedata
ID: 9707323
The section of code goes into each procedure you write.  It traps and reports error occuring in that procedure

  Example:

Private Function IsLoaded(strName As String, Optional lngType As AcObjectType = acForm) As Boolean

  on error goto IsLoaded_Err:

  IsLoaded = (SysCmd(acSysCmdGetObjectState, lngType, strName) <> 0)

Isloaded_Exit:
  on error resume next
  exit function

Isloaded__Err:
    select case err
    case else
      msgbox "Error in MODULENAME.Isloaded: " & err & " - " & Error$
      resume Isloaded__Exit
      resume
    end select

 End Function
0
 

Author Comment

by:CatDaddy2003
ID: 9707373
Ok, something I am still doing wrong. FYI, here are the revised procedures. Any ideas?

*****************************
Private Function IsLoaded(strName As String, _
 Optional lngType As AcObjectType = acForm) As Boolean
 
 On Error GoTo IsLoaded_Err:
 
 IsLoaded = (SysCmd(acSysCmdGetObjectState, lngType, strName) <> 0)
 
Isloaded_Exit:
  On Error Resume Next
  Exit Function

Isloaded__Err:
    Select Case Err
    Case Else
      MsgBox "Error in MODULENAME.Isloaded: " & Err & " - " & Error$
      Resume Isloaded__Exit
      Resume
    End Select

 End Function
 
    IsLoaded = (SysCmd(acSysCmdGetObjectState, _
     lngType, strName) <> 0)
 End Function

*******************************

Private Sub cboKeyCode_NotInList(NewData As String, Response As Integer)
    Dim mbrResponse As VbMsgBoxResult
   
    On Error GoTo cboKeyCode_Err:
   
    cboKeyCode = (SysCmd(acSysCmdGetObjectState, lngType, strName) <> 0)
   
KeyCode_Exit:
  On Error Resume Next
  Exit Function
   
KeyCode_Err:
    Select Case Err
    Case Else
      MsgBox "Error in MODULENAME.Isloaded: " & Err & " - " & Error$
      Resume KeyCode_Exit
      Resume
    End Select

 End Function
   
    Dim strMsg As String

    strMsg = NewData & _
     " isn't an existing Key Code. " & _
     "Add a new Key Code?"
    mbrResponse = MsgBox(strMsg, _
     vbYes + vbQuestion, "Invalid Key Code")
    Select Case mbrResponse
        Case vbYes
            DoCmd.OpenForm "Key Code", _
                DataMode:=acFormAdd, _
                WindowMode:=acDialog, _
                OpenArgs:=NewData
               
                'Stop here and wait until the form goes away
                If IsLoaded("Key Code") Then
                    Response = acDataErrAdded
                    DoCmd.Close acForm, "Key Code"
                Else
                    Response = acDataErrContinue
                End If
        Case vbNo
            Response = acDataErrContinue
    End Select
End Sub
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 32

Expert Comment

by:jadedata
ID: 9707392
Is there any particular reason you changed the order of the sections in the code

  Public Function FuncName()

    dims.....

    on error goto
   
    function code.....

    exit gate....

    error trap....

    End Function
0
 

Author Comment

by:CatDaddy2003
ID: 9707523
Nope just in a hurry and had to leave for a moment. I have revised the procedures as the following, with same results...????????

****************

Private Function IsLoaded(strName As String, _
 Optional lngType As AcObjectType = acForm) As Boolean
 
    On Error GoTo IsLoaded_Err:
   
    IsLoaded = (SysCmd(acSysCmdGetObjectState, _
     lngType, strName) <> 0)
     
IsLoaded_Exit:
        On Error Resume Next
        Exit Function
       
IsLoaded_Err:
    Select Case Err
    Case Else
        MsgBox "Error in MODULENAME.IsLoaded: " & Err & " - " & Error$
        Resume IsLoaded_Exit
        Resume
    End Select
 End Function

****************************

Private Sub cboKeyCode_NotInList(NewData As String, Response As Integer)

    Dim mbrResponse As VbMsgBoxResult
    Dim strMsg As String
   
    On Error GoTo cboKeyCode_Err:
   
   
    strMsg = NewData & _
     " isn't an existing Key Code. " & _
     "Add a new Key Code?"
    mbrResponse = MsgBox(strMsg, _
     vbYes + vbQuestion, "Invalid Key Code")
    Select Case mbrResponse
        Case vbYes
            DoCmd.OpenForm "Key Code", _
                DataMode:=acFormAdd, _
                WindowMode:=acDialog, _
                OpenArgs:=NewData
               
                'Stop here and wait until the form goes away
                If IsLoaded("Key Code") Then
                    Response = acDataErrAdded
                    DoCmd.Close acForm, "Key Code"
                Else
                    Response = acDataErrContinue
                End If
        Case vbNo
            Response = acDataErrContinue
    End Select
   
cboKeyCode_Exit:
    On Error Resume Next
    Exit Function
   
cboKeyCode_Err:
    Select Case Err
    Case Else
        MsgBox "Error in MODULENAME.cboKeyCode: " & Err & " - " & Error$
        Resume cboKeyCode_Exit
        Resume
    End Select
End Sub
0
 
LVL 9

Accepted Solution

by:
ornicar earned 500 total points
ID: 9707715
'invalid outside procedure' indicates when there is code somewhere not between Function...End Function or Sub...End Sub. Check perhaps in the 'Key Code" form, as the error raises when you enter sonething not in list.
0
 
LVL 32

Expert Comment

by:jadedata
ID: 9708739
Compile the project and the compiler should land you on the culprit line immediately.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now