Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Error Message: Invalid Outside Procedure

Posted on 2003-11-08
8
Medium Priority
?
650 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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
 
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 2000 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

705 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