PDA

View Full Version : Solved: Run-time errors



Marcster
09-06-2005, 07:43 AM
Hello people :hi: ,

Can someone post some VBA code that when run will place in a new table all the run-time error numbers and descriptions for Access?. : pray2:

Thanks :thumb,

Marcster.

Norie
09-06-2005, 08:13 AM
Marc

I really don't think that's possible.

Why not just use Help and also the Microsoft Knowledge Base?

:oops:Correction, it probably is possible but why would you want it?

Killian
09-06-2005, 08:49 AM
:yes Sub CreateAccessErrorsTable()

Dim rst As Recordset
Dim tdf As TableDef
Dim fld As Field
Dim lngErrCode As Long
Dim strErrDescription As String
Const APP_OBJ_ERR = "Application-defined or object-defined error"

On Error GoTo Errortrap
' Create table
Set tdf = CurrentDb.CreateTableDef("AccessErrors")
With tdf
.Fields.Append .CreateField("ErrorCode", dbLong)
.Fields.Append .CreateField("ErrorString", dbMemo)
End With

CurrentDb.TableDefs.Append tdf
Set rst = CurrentDb.OpenRecordset("AccessErrors")

'loop through error code index
For lngErrCode = 0 To 32000
On Error Resume Next
strErrDescription = AccessError(lngErrCode)
'skip empty decriptions or
'"Application-defined or object-defined error"
If strErrDescription <> "" Then
If strErrDescription <> APP_OBJ_ERR Then
rst.AddNew
rst!ErrorCode = lngErrCode
rst!ErrorString.AppendChunk strErrDescription
rst.Update
End If
End If
Next lngErrCode

rst.Close
RefreshDatabaseWindow
MsgBox "Access errors table created."
Exit Sub
Errortrap:
MsgBox Err & " - " & Err.Description

End SubEnjoy :)

Marcster
09-07-2005, 01:13 AM
Cheers Killian :beerchug: ,

Works great! :bow: .


Thanks :clap: ,

Marcster.