开发者

Access VBA throwing unlisted error code

开发者 https://www.devze.com 2023-02-06 11:41 出处:网络
I\'m seeing an error code like this in my Access 2000 VBA: -2147352567-Record in \'[SomeTable]\' was deleted by another user.

I'm seeing an error code like this in my Access 2000 VBA:

-2147352567-Record in '[SomeTable]' was deleted by another user.

So, 2 questions:

1) How do I handle/avoid an erro开发者_JAVA技巧r code like this?

2) Can anyone explain why I'm getting an error code that doesn't seem to exist in MS documentation? And is there some way to decipher this code? Is it a combination of several codes? Any guidance on this topic would be appreciated.

Public Sub Form_Open(Cancel As Integer)

' Check for unposted record / regardless of Date / Shift
' If there is an unposeted record goto it

  Dim lCheck
  Dim sPress As String

On Error GoTo Form_Open_Err

GotoRecord:

  If bPressConsumptionOpenRan = True Then
    lCheck = DLookup("PressConsumptionID", "spI_GetUnPostedRecord")
    If Not IsNothing(lCheck) Then
      Me.txtPressConsumptionID.SetFocus
      DoCmd.FindRecord lCheck
    Else
      DoCmd.SetWarnings False
      DoCmd.OpenQuery ("spI_InsertNewPressConsumption")
      Me.Requery
      DoCmd.SetWarnings True
    End If
  End If

Form_Open_Exit:

  Exit Sub

Form_Open_Err:

  sErrMsg = Err.Number & "-" & Err.Description
  MsgBox sErrMsg, vbCritical + vbOKOnly + vbInformation, "Program Error"

So I just commented out the

On Error GoTo

lines in Form_Open(), Form_Load(), and Form_Activate(), and still no debugger call. This error is shown when the db is opened, so I have no idea where else the error could be in the code.

And here is the code for IsNothing:

Public Function IsNothing(vCheck As Variant) As Boolean

On Error GoTo IsNothing_Err

  If IsNull(vCheck) Then IsNothing = True: Exit Function
  If IsEmpty(vCheck) Then IsNothing = True: Exit Function
  If Trim(vCheck) = "" Then IsNothing = True: Exit Function

IsNothing_Err:

  IsNothing = False

End Function

Now I'm getting a similar error in Form_Current():

Private Sub Form_Current()

  Dim sUser As String

On Error GoTo Form_Current_Err

  If IsNothing(Me.dtpUsageDate) Then
    Me.dtpUsageDate = Date   'This line throws error.
  End If

...Ommitted to save space.  Not relevant...

Form_Current_Err:

  sErrMsg = Err.Number & "-" & Err.Description
  MsgBox sErrMsg, vbCritical + vbOKOnly + vbInformation, "Program Error"
  Resume Form_Current_Log

Form_Current_Log:

  On Error Resume Next
  Call LogError(sErrMsg, "PressConsumptions_Form_Current")
  GoTo Form_Current_Exit

End Sub

Error Message:

-2417352567-There is no object in this control.

Is this message related to the other one we've been seeing? Any thoughts on correcting?


The error number and message suggest to me that this is a problem from outside of Access. The fact that you're executing a saved query that has a name suggesting that it runs an SPROC on a database server suggests to me that the back end is SQL Server or some other back end.

It's a very common error in Access when you don't have both a primary key and a timestamp field in your back end table. It's caused by the fact that Access can't tell exactly which record is involved and can't refresh the display appropriately. Having a PK and a timestamp field usually gets rid of the problem.

But it may be caused by something else, of course.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号