代码之家  ›  专栏  ›  技术社区  ›  Harambe

VB6更新错误Sheridan网格

vb6
  •  0
  • Harambe  · 技术社区  · 7 年前

    我正在对另一个使用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”。

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

    错误的原因是什么?我该如何修复它?

    1 回复  |  直到 7 年前
        1
  •  1
  •   David Huthaifah Kholi    7 年前

    是不是 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)