大家好,请求帮助解决删除ACCESS报表的部分记录,提示错误信息“键列信息不足或不正确,更新影响到多行。”
VB程序如下:Private Sub Command3_Click()
Dim strQuery As String
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim ret As Single
Dim ret1, ret2, ret3 As String
Dim mrc As ADODB.Recordset
Dim datestart1, datestart2 As String
Dim dateend1, dateend2 As Stringi = MsgBox("ÄãÈ·ÈÏҪɾ³ýÕâЩ¼Ç¼?", vbOKCancel + vbQuestion + vbDefaultButton2, "¾¯¸æ")
If i = vbCancel Then GoTo AAAdatestart1 = Mid(Format(DTPicker1.Value, "yyyy-mm-dd"), 1, 10) & " " & "0:00:00"
dateend1 = Mid(Format(DTPicker2.Value, "yyyy-mm-dd"), 1, 10) & " " & "9:59:59"
datestart2 = Mid(Format(DTPicker1.Value, "yyyy-mm-dd"), 1, 10) & " " & "10:00:00"
dateend2 = Mid(Format(DTPicker2.Value, "yyyy-mm-dd"), 1, 10) & " " & "23:59:59"If Combo1.Text = "ËùÓÐ" Then
strQuery = "select * from Cashparameter where IDºÅ = 'ºÏ¼Æ' or ÈÕÆÚ >= '" & datestart1 & "' and ÈÕÆÚ <= '" & dateend1 & "' or ÈÕÆÚ >= '" & datestart2 & "' and ÈÕÆÚ <= '" & dateend2 & "' "
Else
strQuery = "select * from Cashparameter where IDºÅ = 'ºÏ¼Æ' or Ãû³Æ = '" & Combo1.Text & " '  and ÈÕÆÚ >= '" & datestart1 & "' And ÈÕÆÚ <= '" & dateend1 & "' or Ãû³Æ  = '" & Combo1.Text & " '  and ÈÕÆÚ >= '" & datestart2 & " ' and ÈÕÆÚ <= '" & dateend2 & "' "
'strQuery = "select * from Cashparameter where  IDºÅÔ± = '" & Combo1.Text & " '  and ÈÕÆÚ >= '" & DTPicker1.Value & " ' and  ÈÕÆÚ <= '" & DTPicker2.Value & " ' "
End If
datPrimaryRS.RecordSource = strQuery
datPrimaryRS.Refresh
      
      
If datPrimaryRS.Recordset.RecordCount = 0 Then
GoTo AAA:
Else
For i = 1 To datPrimaryRS.Recordset.RecordCount
  'On Error GoTo DeleteErr
  With datPrimaryRS.Recordset
    .Delete
    .MoveNext
 '   If .EOF Then .MoveLast
  End With
'DeleteErr:
'  MsgBox Err.Description
Next i
End IfAAA:
Call Delay(0.1, True)
strQuery = "select *  from Cashparameter"
datPrimaryRS.RecordSource = strQuery
datPrimaryRS.Refresh
Call Delay(0.1, True)
 Command1.Visible = False
 Command3.Visible = False
 Command2.Visible = False
 Combo1.Visible = False
 DTPicker1.Visible = False
 DTPicker2.Visible = False
 Label1.Visible = False
 Label2.Visible = False
 Label3.Visible = False
 grdDataGrid.Visible = True
 cmdClose.Visible = True
 datPrimaryRS.Visible = True
 cmdquery.Visible = True
 cmdput.Visible = True
 cmdRead.Visible = True
 'cmdsave.Visible = True
 cmdDelete.Visible = True
 
strQuery = "select *  from Cashparameter"
datPrimaryRS.RecordSource = strQuery
datPrimaryRS.Refresh
End Sub