Re: Access 2007 ODBC Error Trapping



Mark,

Thanks for replying, but obviously, you did not read and understand my
problem.
All you posted was a canned reply.
I specified that I am working with ODBC and the dbengine errors collection,
which is reporting the wrong error.
Plus, you code is completely wrong.
In the Form_Error event, the error number is contained in the DataErr
argument, NOT the access error object.
In the Form_Error event, Err.Number is 0 and Err.Description is empty.

As I already specified, the error is 3146, ODBC call failed.
At that point, I should be able to get the real error from the dbengine
errors collection, but that is reporting the incorrect error.

No, your response is not at all helpful.

Sample code?

Private Sub Form_Error(DataErr As Integer, Response As Integer)
Dim strErr As String
Dim intErr As Integer

strErr = "Access error " & CStr(DataErr) & " " & AccessError(DataErr)
If DBEngine.Errors.Count > 0 Then
strErr = strErr & vbCrLf & "DbEngineErrors:"
For intErr = 0 To DBEngine.Errors.Count - 1
strErr = strErr & vbCrLf & DBEngine.Errors(intErr).Number & " / " &
DBEngine.Errors(intErr).Description & " / " & DBEngine.Errors(intErr).Source
Next
End If
MsgBox strErr, vbCritical, "Not What Is Desired"
End Sub

This result is:
Access error 3146 ODBC--call failed.
DbEngineErrors:
3021 / No current record. / DAO.Recordset

I would expect something like:

Access error 3146 ODBC--call failed.
DbEngineErrors:
515 / ...column does not allow null... / DAO.Recordset

Or, am I looking in the wrong place to get the actual error?

Can anyone offer a solution?

--

AG
Email: npATadhdataDOTcom


"Mark Han[MSFT]" <v-fathan@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:$6nBUwknJHA.1700@xxxxxxxxxxxxxxxxxxxxxxxxx
Hi AG,

Thank you for using Microsoft MSDN Managed Newsgroup. My name is Mark Han.
I am glad to work with you on this issue.

From your description, I understand that you would like to trap the error
in the form error event. However the error captured is always 3021. not
the
actual error code. If I have misunderstood, please let me know.

in order to address your concern, I make an example here.

Visual Basic Error event arises when a run-time error occurs in Access on
the current form.

Error Event Visual Basic Example:
It is good practice to have an On Error event handler in each form. In
this example we simply trap the error and display a message to the userr.

Private Sub Form_Error(DataErr As Integer, Response As Integer)
Msgbox "An unexpected error has occurred in the form. " & _
"The error description is " & err.description
Response = acDataErrContinue
End Sub

The response argument can have either of two values:

acDataErrContinue: Ignore the error and continue without displaying the
Microsoft Access error message.


acDataErrDisplay: Display the Microsoft Access error message. This is the
default setting.

Hope the above helpful.

Besides, in order to better assist you with the issue, if it is convenient
to you, please post the error event code here.

I look forward to hearing from you.

Best regards,
Mark Han
Microsoft Online Community Support
===========================================================
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: msdnmg@xxxxxxxxxxxxxx
===========================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or
a Microsoft Support Engineer within 2 business day is acceptable. Please
note that each follow up response may take approximately
2 business days as the support professional working with you may need
further investigation to reach the most efficient resolution.
The offering is not appropriate for situations that require urgent,
real-time or phone-based interactions. Issues of this nature are
best handled working with a dedicated Microsoft Support Engineer by
contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx

============================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
=========================================================



.



Relevant Pages

  • Re: .NET Adoption Statistics
    ... Are your applications currently built upon .net framework 2.0? ... I'm sure only a few Microsoft solution parnters ... Microsoft MSDN Online Support Lead ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework)
  • RE: Windows Form Does Not Close When Using X on ControlBox on Fo
    ... Jeff, Thanks for the response. ... The code-behind stuff in the Microsoft Generated ... I'll try to duplicate the problem with a much smaller and more ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.framework.windowsforms)
  • RE: Offer Remote Assistance Not Working
    ... I am sorry for the delayed response due to weekend. ... will cost you time and energy, and we do not support this method in Public ... Microsoft CSS Online Newsgroup Support ...
    (microsoft.public.windows.server.sbs)
  • RE: ClickOnce program fails to run properly after update
    ... If you update the application with custom upgrade behavior, ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.languages.vb)
  • RE: ClickOnce program fails to run properly after update
    ... If you update the application with custom upgrade behavior, ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.distributed_apps)