Run time error 2001

  • Thread starter Thread starter =?iso-8859-1?Q?Niklas_=D6stergren?=
  • Start date Start date
?

=?iso-8859-1?Q?Niklas_=D6stergren?=

Hi!

I´d like to know more about run time error 2001 and have tryed to look for it in the helpfile of A2003. But the only error numbers I can find is <Trappable Errors> and there isn´t any description of error number 2001.

Where can I find information about error numbers? I´m going to know this in the future since I have planed NOT to write full proof code ;-)

TIA!
// Niklas
 
Error 2001 means that Access is unable to complete the current operation
because something else needed to happen first.

A typical example, is if you misspell a field name in a DLookup() argument,
or when setting the Filter of a form. It immediately accepts the string, but
when it goes to use it, it fails. In this context, check your spelling,
spaces, square brackets, etc.

Likewise, if you try to move to a different record in a form, but the
current record is can't be saved (e.g. a required field is missing), then
the move fails because the previous thing (saving the record) failed. It's a
good idea to explicitly save before anything that requires the record to be
saved, e.g. closing the form, filtering the form, changing the sort order,
reassigning the recordsource, finding another record, ...

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Hi!

I´d like to know more about run time error 2001 and have tryed to look for
it in the helpfile of A2003. But the only error numbers I can find is
<Trappable Errors> and there isn´t any description of error number 2001.

Where can I find information about error numbers? I´m going to know this in
the future since I have planed NOT to write full proof code ;-)

TIA!
// Niklas
 
Thank´s a lot Allen!

It was a missspelled fieldname in a DLookup() that was my problem. Now
everything works just fine.

But back to one of my Q, where do I find more information about all type of
error numbers? Because I´m sure I´m going to need it in the future, quite
soon I think :-)

// Niklas
 
This is some code posted by Doug Steele, awhile ago, to answer a similar
question.

Create a blank db, copy and paste this code to a new module and run it.
Make sure you reference DAO.

As noted below, it is not a complete list, but most of the common error
codes are here.

Rosco


'The following procedure creates a table containing many of the error codes
'and strings used or reserved by Microsoft Access and by the Microsoft Jet
'database engine. Not all error codes are included in the resulting
'table, as
'some exist outside the range of error codes evaluated by this procedure (0
'to 4500).

Function AccessAndJetErrorsTable() As Boolean
Dim dbs As Database, tdf As TableDef, fld As DAO.Field
Dim rst As DAO.Recordset, lngCode As Long
Dim strAccessErr As String
Const conAppObjectError = "Application-defined or object-defined error"

On Error GoTo Error_AccessAndJetErrorsTable
' Create Errors table with ErrorNumber and ErrorDescription fields.
Set dbs = CurrentDb
Set tdf = dbs.CreateTableDef("AccessAndJetErrors")
Set fld = tdf.CreateField("ErrorCode", dbLong)

tdf.Fields.Append fld
Set fld = tdf.CreateField("ErrorString", dbMemo)
tdf.Fields.Append fld

dbs.TableDefs.Append tdf
' Open recordset on Errors table.
Set rst = dbs.OpenRecordset("AccessAndJetErrors")
' Loop through error codes.
For lngCode = 0 To 3500
On Error Resume Next
' Raise each error.
strAccessErr = AccessError(lngCode)
DoCmd.Hourglass True
' Skip error numbers without associated strings.
If strAccessErr <> "" Then

' Skip codes that generate application or object-defined errors.
If strAccessErr <> conAppObjectError Then
' Add each error code and string to Errors table.
rst.AddNew
rst!ErrorCode = lngCode
' Append string to memo field.
rst!ErrorString.AppendChunk strAccessErr
rst.Update
End If
End If
Next lngCode
' Close recordset.
rst.Close
DoCmd.Hourglass False
RefreshDatabaseWindow
MsgBox "Access and Jet errors table created."

AccessAndJetErrorsTable = True

Exit_AccessAndJetErrorsTable:
Exit Function

Error_AccessAndJetErrorsTable:
MsgBox Err & ": " & Err.Description
AccessAndJetErrorsTable = False
Resume Exit_AccessAndJetErrorsTable
End Function
 
Hi Rosco!

Thank´s a lot!

That might be usefull so I´ll keep on filling this db with information about
the error´s that I come over. With more detailed information which might be
helpfull.

// Niklas
 
Back
Top