Solved

Error Message: Invalid Outside Procedure

Posted on 2003-11-08
8
622 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
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.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

895 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

13 Experts available now in Live!

Get 1:1 Help Now