|
|
Error Codes
[edit] Error HandlingFor information regarding error handling and debugging, please refer to the following pages:
For other error code related problems:
[edit] Debugging / How to for BEGINNERS[edit] 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 [edit] Err: 9, Subscript out of range
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 [edit] #Error, #Num!, #Name?, #Div/0!, #Deleted, #Locked[edit] Err: 49, Bad DLL calling convention49_-_Bad_DLL_Calling_Convention
[edit] Err: 91,Object variable or With block variable not set
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 [edit] 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 !
[edit] 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) [edit] Unexpected Type Mismatch[edit] User-defined type not definedCODE Sub Test_Excel() ' Error: User-defined type not defined Dim oWBook As Excel.Workbook End Sub
[edit] Out of Stack Space
[edit] Not enough space on temporary disk
[edit] 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 [edit] Variable not defined
[edit] LBL_xPAC_END:
[edit] LBL_xPAC_ERR:
[edit] Microsoft Office Access was unable to create an MDE database
[edit] Could not use 'YourDatabaseFullName'; file allready in use.
[edit] Err:-2147217887, The Microsoft Jet database engine stopped the process because you and another user are attempting..[edit] Crazy ErrorsOn the First Try Error, But on the Second, Third,..OK
CODE Resume [edit] Crash/ Microsoft Office Access has encountered a problem and needs to close..[edit] Unknown Jet ErrorIf 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]; [edit] Write Conflict
SQL CurrentProject.Connection.Execute "UPDATE Table1 AS A SET A.Field1 = 'QueryValue';"
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..
[edit] Type Conversion FailureType Conversion Failure Occurs When Importing Microsoft Excel Data.. [edit] Others
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This page was last modified 11:51, 25 January 2012. This page has been accessed 21,600 times. Disclaimers |