Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17
  1. #16
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    mks123,

    Glad you found a solution. My initial concerns were why are you using ADODB? And what exactly were you trying to accomplish in plain, simple English?
    I don't think my adjustment to your code, or the solution at the link you provided are necessarily appropriate solutions. But, then again, readers don't know your business issue in any detail.

    As for the code you asked about:
    Code:
    140     With Errloop
    150         strTmp = strTmp & vbCrLf & "ADO Error # " & i & ":"
    160         strTmp = strTmp & vbCrLf & "   ADO Error   # " & .number
    170         strTmp = strTmp & vbCrLf & "   Description   " & .Description
    180         strTmp = strTmp & vbCrLf & "   Source        " & .source
    190         i = i + 1
    200     End With
    210   Next
    220       Debug.Print strTmp
    230       MsgBox strTmp
    I don't use ADODB very often. I use DAO almost exclusively.
    Anyway, I used google to find


    https://support.microsoft.com/en-us/...ordset-objects
    Review the ERROR NOTES in the article for specifics.

    I recommend that you include Option Explicit in your modules to force Dimming all variables.

    ADO Connection object has an errors collection.



    Code:
     'must DIM variables to be used
        Dim errs1 As ADODB.Errors  'this is the Errors Collection
        Dim Errloop As ADODB.Error 'this is an individual Error 
        Dim strTmp As String       ' this is to hold the ADODB.Error text 
    .....
    .....
    120   Set errs1 = Conn.Errors
    
    'this code loops through each Error in the Errors Collection
    'which means there can be 0,1, or many error(s) found for the Connection object
    130   For Each Errloop In errs1
    140     With Errloop
    
    'this code builds up a message for any/all errors found
    150         strTmp = strTmp & vbCrLf & "ADO Error # " & i & ":"
    160         strTmp = strTmp & vbCrLf & "   ADO Error   # " & .number
    170         strTmp = strTmp & vbCrLf & "   Description   " & .Description
    180         strTmp = strTmp & vbCrLf & "   Source        " & .source
    190         i = i + 1
    200     End With
    210   Next
    
    'this line Prints the ADODB message to the immediate window
    220       Debug.Print strTmp
    
    'this line outputs the MsgBox to the screen
    230       MsgBox strTmp
    
    'this is my error handler from MZTools
    240   MsgBox "Error " & err.number & " in line " & Erl & " (" & err.Description & ") in procedure AddRecord of Module ModuleTesting_CanKill"
    
    End Sub
    Good luck.

  2. #17
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Also note that "Time" is a reserved word and shouldn't be used for object names!

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums