UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> Error Codes    
Error Codes

Image:NotifCleanup.gif This page requires general cleanup in formatting or text to better fit the UA Wiki Guidelines

Contents

Error Handling

For information regarding error handling and debugging, please refer to the following pages:

For other error code related problems:

Debugging / How to for BEGINNERS

Err: 3, Return without GoSub

CODE

Sub Test_Errors()
'------------------------- INITIALISE ERROR HANDLER
On Error GoTo LBL_xPAC_ERR
'------------------------- INITIALISE VARIABLES
Dim i As Long
Dim ll_DoError_3 As Boolean
'========================= START MAIN ROUTINE =========================================
ll_DoError_3 = True      ' True=Error, False=OK
If ll_DoError_3 Then
   GoTo MySubroutine    ' Err: 3,Return without GoSub
Else
   GoSub MySubroutine   ' OK, GoSub: Goto MySubroutine and Return Back
End If
'------------------------ Mark 'Exit Sub' for ERROR HANDLER ,with Label 'LBL_xPAC_END:'
LBL_xPAC_END:
   Exit Sub
'======================== Exit Sub: END/EXIT-CODE =====================================
'------------------------ Mark **Start** of 'MySubroutine' with Label 'MySubroutine:'
MySubroutine:
   i = i + 1
'------------------------ Mark **End** of 'MySubroutine' with command 'Return'
Return                  ' Return to Call-LINE: GoSub MySubroutine
'------------------------ Mark ERROR HANDLER **Start**, with Label 'LBL_xPAC_ERR:'
LBL_xPAC_ERR:
   Debug.Print "Err: " & Err & "," & Err.Description
   MsgBox "Err: " & Err & "," & Err.Description, vbCritical, "Test_Errors"
'----------------------- CLEAR ERROR, and go to Line with Label 'LBL_xPAC_END:'
   Resume LBL_xPAC_END
'----------------------- CLEAR ERROR, and go to **Next Line**
   Resume Next
'----------------------- CLEAR ERROR, and try **the same Line** AGAIN
   Resume
End Sub

Image:ACC TEST ERRORS.JPG

Err: 9, Subscript out of range

  1. First Insert Class code ( VBE_Menu,Class Module )
  2. Then VBE_Menu,Save Your_Database_Name as CLS_ARRAY_01
oMyArray1
ElementValue Subscript
(ElementIndex)
ElementsCount
GetElementsCount
IndexFirst
GetElementIndexFirst
IndexLast
GetElementIndexLast
Index RANGE
Initialised with: Dim
NONE Elements
NONE 0 -1
(NONE)
-2
(NONE)
NONE
ElementValue-1
oMyArray1.GetElementValue(0)
0
(starts at 0,see: Option Base)
1 0 0 0-0
ElementValue-2
oMyArray1.GetElementValue(1)
1 2 0 1 0-1
NOT Defined,**Error** !
oMyArray1.GetElementValue(3)
3
(Subscript[3] out of range[0-1])
2 0 1 0-1
CODE

Function Test_Error_9()
Dim lc_ProcName As String
Dim i As Long, lv1 As Variant
Dim oMyArray1 As CLS_ARRAY_01
On Error GoTo LBL_xPAC_ERR
lc_ProcName = "Test_Error_9"
Set oMyArray1 = New CLS_ARRAY_01
lv1 = oMyArray1.GetElementValue(3)
oMyArray1.AddNewElement "ElementValue-1"
oMyArray1.AddNewElement "ElementValue-2"
For i = oMyArray1.GetElementIndexFirst To oMyArray1.GetElementIndexLast
   MsgBox _
       (i + 1) & ".ElementValue = " & oMyArray1.GetElementValue(i), _
       vbInformation, lc_ProcName
Next i
MsgBox _
   "(Array.GetElementsCount)" & vbCrLf & _
   "Array has " & oMyArray1.GetElementsCount & " Elements now." & vbCrLf & _
   "First Element Index = " & oMyArray1.GetElementIndexFirst & vbCrLf & _
   "Last Element Index = " & oMyArray1.GetElementIndexLast, _
   vbInformation, lc_ProcName
MsgBox _
   "First Element Value = " & _
   oMyArray1.GetElementValue(oMyArray1.GetElementIndexFirst) & vbCrLf & _
   "First Element Index = " & oMyArray1.GetElementIndexFirst, _
   vbInformation, lc_ProcName
MsgBox _
   "Last Element Value = " & _
   oMyArray1.GetElementValue(oMyArray1.GetElementIndexLast) & vbCrLf & _
   "Last Element Index = " & oMyArray1.GetElementIndexLast, _
   vbInformation, lc_ProcName
lv1 = oMyArray1.GetElementValue(3)
LBL_xPAC_END:
   Set oMyArray1 = Nothing
Exit Function
LBL_xPAC_ERR:
   MsgBox "Err: " & Err & "," & Err.Description, vbCritical, lc_ProcName
   Resume Next
   Resume
   Resume LBL_xPAC_END
End Function

#Error, #Num!, #Name?, #Div/0!, #Deleted, #Locked

Err: 49, Bad DLL calling convention

49_-_Bad_DLL_Calling_Convention

Err: 91,Object variable or With block variable not set

Action SECTION-1
**DIM**
SECTION-2
**SET**
SECTION-4
**CLEANUP-OBJECT**
IsVariableObjectType
IsObject(RS1)
True True True
IsVariableObjectType
(VarType(RS1) = vbObject)
True True True
TypeName(RS1) Nothing Recordset Nothing
(RS1 Is Nothing ) True False True
IsObjectVariable_Nothing
(I Can NOT use Object/RS1)
True / YES False / NO True / YES
IsObjectVariable_Object
(Can i use Object/RS1)
False / NO True / YES False / NO
CODE

Public Sub Test_Error_91()
'-- SECTION-1 **DIM** -------------------------------
   On Error GoTo LBL_xPAC_ERR
   Dim ll_DoError_91 As Boolean
   'Dim RS1 As ADODB.Recordset
   Dim RS1 As Object
   Const lkc_ProcedureName = "Test_Error_91"
   GoSub F_SHOW_OBJECT
'-- SECTION-2 **SET** -------------------------------
   ll_DoError_91 = (MsgBox("DoError_91 ?", _
       vbExclamation + vbYesNo + vbDefaultButton1, lkc_ProcedureName) = vbYes)
   If ll_DoError_91 Then
       'DO Nothing here, SKIP **SET** !!!
   Else
       Set RS1 = CreateObject("ADODB.Recordset")
       'Set RS1 = New ADODB.Recordset
       'Do not forget CLEANUP: Set RS1 = Nothing
   End If
   GoSub F_SHOW_OBJECT
'-- SECTION-3 **CALL OBJECT METHOD/OPEN** -----------
   'If Object/RS1 Is Nothing then Error occurs..
   RS1.Open "Table1", _
   CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly, adCmdTable
   'After **Open** Do not forget **CLOSE**
   If (RS1.BOF And RS1.EOF) Then
       Err.Raise 1111, lkc_ProcedureName, _
               "Add rows, Recordset/Table is *EMPTY* !(without rows)"
   Else
       Do Until RS1.EOF
           Debug.Print "RS1.Fields(0).Value=" & RS1.Fields(0).Value
           RS1.MoveNext
       Loop
   End If
   Debug.Print "----------------------------------------"
LBL_xPAC_END:
'-- SECTION-4 **CLEANUP-OBJECT** -------------------
   If Not RS1 Is Nothing Then          ' Check Object Is/exists ?
       If RS1.State = adStateOpen Then ' Check Object State, if is **OPEN** then..
           RS1.Close        ' If you **OPEN** Object/recordset..,You NEED **CLOSE** it
       End If
   ' release memory and system resources associated with the object
       Set RS1 = Nothing ' CLEANUP-OBJECT ( CALL AFTER **CLOSE**-OBJECTS !)
   End If
   GoSub F_SHOW_OBJECT
Exit Sub
'==================================================
F_SHOW_OBJECT:
   Debug.Print "IsVariableObjectType/IsObject(RS1)=" & IsObject(RS1)
   Debug.Print "IsVariableObjectType/(VarType(RS1)=vbObject)=" & (VarType(RS1) = vbObject)
   Debug.Print "TypeName(RS1)=" & TypeName(RS1)
   Debug.Print "(RS1 Is Nothing)=" & (RS1 Is Nothing)
   Debug.Print "IsObjectVariable_Nothing(I Can NOT use Object/RS1)=" & (RS1 Is Nothing)
   Debug.Print "IsObjectVariable_Object (Can i use Object/RS1)=" & Not (RS1 Is Nothing)
   Debug.Print "----------------------------------------"
Return
'--------------------------------------------------
LBL_xPAC_ERR:
   MsgBox _
       "Err: " & Err & "," & Err.Description, vbCritical, lkc_ProcedureName
   Resume LBL_xPAC_END
   Resume Next
   Resume
End Sub

Err: 94, Invalid use of Null

CODE

Dim str1 As String,var1 As Variant
str1 = Null ' Error: 94,Invalid use of Null , String str1 CAN NOT contains Nulls !
str1 = Nz(Null) ' OK
var1 = Null     ' OK, Variant Variable CAN contains Nulls !

You do not have the necessary permissions to use the object

CODE

DBEngine.Idle

If still error try Rebuild your Database if you are Administrator (Corruption is there)

Unexpected Type Mismatch

User-defined type not defined

CODE

Sub Test_Excel()
' Error: User-defined type not defined
Dim oWBook As Excel.Workbook
End Sub

Out of Stack Space

Not enough space on temporary disk

My Custom Errors ?

Err.Raise 1111, "SysVerifyPathExists", "*EMPTY* Path !"

CODE

If Expression Then
   ' Condition = True, then do something..
Else
   ' Condition = False, I can **NOT** do something !!
   Err.Raise 1111, lkc_ProcedureName, _
       "Trap-Error: File/Form/Table/...-Name is **EMPTY / NOT EXISTS / ..** !"
End If
CODE

Sub Test_SelectCase1()
   Dim ln_Verify_CUR As Long, ln_Verify_MAX As Long
   Const lkc_ProcedureName = "Test_SelectCase1"
ln_Verify_CUR = 10       ' Initialize variable.
ln_Verify_MAX = 16       ' Initialize variable.
' ... -20 ======= -10 ======= 0 ======= +10 ======= +20 == +30 ...
' ...!!!!!!!!!!!!!!!!!!!!!!!!!<123456789>!!!!!<17,18,.............>
Select Case ln_Verify_CUR ' Evaluate Number: ln_Verify_CUR
   Case 1 To 5                    ' Number between 1 and 5, inclusive
       ' DoAction.......Between 1 and 5
   Case 6, 7, 8                   ' Number In List
       ' DoAction.......Between 6 and 8
   Case 9
       ' OK...( DoNothing, place Comment Text here, you know LATER it is OK )
   Case Is > ln_Verify_MAX
       ' DoAction.......Greater than ln_Verify_MAX
   Case Else                      ' Other values are ***NOT VALID*** !!!
       Err.Raise Number:=1111, Source:=lkc_ProcedureName, _
           Description:=ln_Verify_CUR & ", Unexpected value of ln_Verify_CUR !"
End Select
End Sub

Variable not defined

' --------------------------------------------------Module Declaration Section-Start-----------------------------
Option Explicit ' Automatically check Variable Declaration in your code,VBE_Menu,Options...
Option Compare Database
#Const mflg_UseLateBinding = True ' <- conditional compiler constant for THIS MODULE
#Const mflg_DebugMode = True ' <- conditional compiler constant for THIS MODULE
Public Const gkc_DriveFrontEnd = "C"
Private Const mkc_ModuleName = "MOD_Main"
' --------------------------------------------------Module Declaration Section-End
Sub Test1()
On Error Goto LBL_xPAC_ERR ' Initialize Error Handler
' --------------------------------------------------Procedure Declaration Section-Start--------------------------
Dim lc_MyVariable As String 'If this Line is Missing, then Error occurs !
#If mflg_UseLateBinding Then
Dim RS_QryNames As Object ' <<- conditional CODE
#Else
Dim RS_QryNames As ADODB.Recordset ' <<- conditional CODE, for Beginners
#End If
Const lkc_ProcedureName = "Test1.V01"
' --------------------------------------------------Procedure Declaration Section-End
' <= Singelquote/Comment-Marker Hold: ALT' and Press: 39 , This Text AFTER Singel _
quote is my comment, this Line is **NOT** executed..
10 lc_MyVariable = "MyText" ' Error: Variable not defined , means Missing Dim Statement in your Sub..
20 Set RS_QryNames = CurrentProject.Connection.OpenSchema( adSchemaViews )
'-------> for Constant ADODB.adSchemaViews/adSchemaViews Add VBE_Menu,References...Library ADODB
LBL_xPAC_END:
'Verify CLEANUP..<-----------------------------------------------------------------------------------------------------------------------
Exit Sub '<--------------------------------------------------------------------------------------------------------------------------------
LBL_xPAC_ERR:
'Show Error..<-----------------------------------------------------------------------------------------------------------------------
Resume LBL_xPAC_END '<-------------------------------------------------------------------------------------------------------------
End Sub

Microsoft Office Access was unable to create an MDE database

Could not use 'YourDatabaseFullName'; file allready in use.

Err:-2147217887, The Microsoft Jet database engine stopped the process because you and another user are attempting..

Crazy Errors

On the First Try Error, But on the Second, Third,..OK

  • Microsoft Office Outlook, -2147221219, The Microsoft Exchange Server computer is not available. Either there are network problems or the Microsoft Exchange Server computer is down for maintenance.
    • wait a minute and try again...
CODE

Resume

Crash/ Microsoft Office Access has encountered a problem and needs to close..

Unknown Jet Error

If you are in VBE_Menu,Break mode , you **CAN NOT** execute/open Query with User-Defined-Function in Database Window.

SQL

SELECT [My_Column1], My_UserDefinedFunction([My_Column2]) AS [My_Result] FROM [My_Table1];

Write Conflict

Image:AC_Wiki_pacala_ba_Write_Conflict_ErrorMsg.JPG Image:AC_Wiki_pacala_ba_Write_Conflict_Table.JPG

  1. Create Table1
  2. Change (Writing Pen on The Left appears) the Value of Field1, and do not EXIT row.
  3. Run this SQL-command from VBE_Menu,Immediate Window
  • Or REOPEN your Database Table in NEW Session Ac_Menu,Open... and change (Writing Pen on The Left appears) the Value of Field1, and then EXIT row in this NEW Session.
SQL

CurrentProject.Connection.Execute "UPDATE Table1 AS A SET A.Field1 = 'QueryValue';"
  1. Now go to Row with ID=2, and Error occurs.. (Locking Behavior-more info..)

You can try this also by changing the Ac_Menu,Options...Default_Record_locking value (Set Options (Database environment) from Visual Basic) . But you must RE-OPEN table to take options-changes..

  • Default_Record_locking=No Locks
    • Error: Write Conflict
  • Default_Record_locking=Edited record
    • Error: Could not update; currently locked by another session on this machine.
  • Default_Record_locking=All Records
    • Error: The table 'Table1' is already opened exclusively by another user, or it is already open through the user interface and cannot be manipulated programmatically.

Image:AC_Wiki_pacala_ba_Write_Conflict_Options_Default_Record_locking.JPG

Type Conversion Failure

Type Conversion Failure Occurs When Importing Microsoft Excel Data..

There was an error loading an ActiveX control on one of your forms or reports.

Others

  • Or look at some other Links
Edit Discussion
Custom Search
Thank you for your support!
This page has been accessed 59,891 times.  This page was last modified 11:35, 10 October 2012 by pacala_ba. Contributions by Jack Leach  Disclaimers