1
votes

I have an Access 2007 database. It uses SharePoint 2010 linked lists as the tables. I have multiple forms that keep getting an error number "0". I get this error in these scenarios:

  • click in a comboBox, that uses a SharePoint list as its source, then type text that is not on the list. (the "limit to list" property must be true). If this property is false, then I don't get the error and everything works fine, but this must be set to true for this specific database.

  • lose connection to SharePoint, then click on an object (comboBox etc) that uses a SharePoint list as its source. There is code in an "Got_Focus" sub that pulls data from the list.

If I catch error number 0 and take care of that, immediately after, the real description displays. For instance, in the first scenario after catching 0 the error "item not on list" box will show, which is a real error (2237) and the second a "can't find record source" box will show, error 2580. However, I can't catch those errors, and if I put in a message box to display the error number after catching error 0, it never displays/or activates.

It seems I get the error 0 consistently when the "Limit to list" property is set to true. I've tried to do "On_Load" sub set Limit to List to true, and "On_close" set to false, however this causes an error can't find object on the "On_Close()" sub. Here is a sample:

   Private Sub Got_Focus()

   On Error GoTo catchError

   Me.Requery    \\This could be any code that "pings" the SharePoint List

  exit_catchError:
  Exit Sub

  catchError:

  If Err.Number = 0 Then Resume Next \\i'v tried with and without this. Gives error 20 with
                                           \\ Also tried If Then with Err.Number = 0
  If Err.Number = 2580 Then              \\Doesn't catch
     MsgBox "Reconnect to SharePoint"
  ElseIf Err.Number = 2237 Then          \\Doesn't catch
     MsgBox "Text not on List"
  Else
     MsgBox Err.Number & " " & Err.Description
  End If

  End Sub
3

3 Answers

3
votes

Error code 0 indicates the absence of an error condition. The only time I've seen a messagebox about Error 0 is when I have missed putting Exit Sub before the error handler. If you take the Exit Sub out of your code above, the body of the sub will run and then the error handler will start. The Else clause will run, prompting a message box with just 0 in it. Is this a possibility?

0
votes

I fixed it by using DataErr rather than Err.Number. I also took out the else statement to show a msgbox. It seems to work just fine now.

0
votes

I just tracked down something like this where I would get an "error 0" displayed in a control whenever the source of the control was a formula; but if it was just a table column, it had no error. For example, if the source of the control was "[colA]", no error message. If the source of the control was "=[colA]", get an "Error 0" message. The problem turned out to be that the control had defaulted to the name "colA". The fix was to rename the control.