关于msflexgrid中的保存问题!
DLMG 2003-05-23 08:45:50 我用access编的数据库,用msflexgrid加载,添加新数据保存后,出现以下的英文提示:the changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. change the data in the field or fields that contain duplicate data,remove the index, or redefine theindex to permit duplicate entries and try again.
请问各位这是什么意思啊?
我的保存程序是这样写的:
Private Sub Command6_Click() '保存按钮
Dim i As Integer
On Error GoTo saveerror
Text3.Visible = False '消除文本框的显示
If addrecord = True Then '是否在添加状态
'On Error GoTo saveadd_modifyerror
BeginTrans
For i = re1.RecordCount To row_num - 1 '将添加部分写入数据库
If grid(i, gridcol_0) <> "" Then '每一行的第0列是否为空白
re1.AddNew '增加一组空白记录
writerecord i '将窗口显示登陆至记录上
re1.Update '将记录写入数据库
End If
Next
CommitTrans
re1.Requery '重新排序
displayrecord
addrecord = False
End If
Exit Sub
'saveadd_modifyerror:
'Rollback
'MsgBox Err.Description
saveerror:
MsgBox Err.Description
End Sub
Public Sub writerecord(r As Integer)
Dim i As Integer
MSFlexGrid1.Row = r '换至第r行
For i = gridcol_0 To gridcol_9
MSFlexGrid1.Col = i '移动至第i列
If MSFlexGrid1.Text = "" Then
re1.Fields(i) = Null
Else
re1.Fields(i) = MSFlexGrid1.Text
End If
Next
End Sub