VB6 更新错误 Sheridan Grid

VB6 Update Error Sheridan Grid

我正在对另一个开发人员编写的使用 SSDB 网格的程序进行一些更改。

我正在为 BeforeUpdate 方法编写代码。

On Error GoTo BeforeUpdate_Err

Dim ans%

ans% = MsgBox("These changes will be committed to the database. These changes cannot be undone. " & _
                    "Would you like to continue?", vbYesNo, "Confirm Changes")

If ans% = 7 Then
    Grd_Collection.CancelUpdate
End If

Exit Sub

BeforeUpdate_Err:
    MsgBox (Err.Description)

网格的唯一其他代码是 InitColumnProps 方法。

但是,在点击 Exit Sub 行后,我收到一条错误消息 "Update Error"。

我已经搜索了这个硬编码的代码,但它不是,所以它来自网格。

是什么导致了错误,我该如何解决?

BeforeUpdate方法不是传入整数吗? (Cancel As Integer) 什么的?

因此,您应该能够将您的代码更改(并整理)如下:

On Error GoTo BeforeUpdate_Err

If MsgBox("These changes will be committed to the database. These changes cannot be undone. " & _
                    "Would you like to continue?", vbYesNo, "Confirm Changes") = vbNo Then

    Cancel = 1
End If

Exit Sub

BeforeUpdate_Err:
    MsgBox (Err.Description)