probleme with update data by using dao

  • Thread starter Thread starter hassan
  • Start date Start date
H

hassan

hi every body

i have problem when i try update exist datea the massege runtime error
3022 appear

i used DAO and this is the code
Private Sub Command26_Click()
Dim rs As DAO.Recordset
Dim strSourceTable As String
Set LAMA = CurrentDb
Set rs = LAMA.OpenRecordset("patient", dbOpenDynaset)
'If rs.BOF = False Then
rs.Edit
rs!pid = [Forms]![P1]![pid]
rs!pname = [Forms]![P1]![pname]
rs!gender = [Forms]![P1]![gender]
rs!age = [Forms]![P1]![age]
rs!tel = [Forms]![P1]![tel]
rs!address = [Forms]![P1]![address]
rs!remark = [Forms]![P1]![remark]
rs.update

rs.Close
pid = Null
pname = Null
gender = Null
age = Null
tel = Null
address = Null
remark = Null
'Me.pid.Locked = True
Me.pname.Locked = True
Me.age.Locked = True
Me.tel.Locked = True
Me.address.Locked = True
Me.remark.Locked = True
Me.gender.Locked = True
Set LAMA = Nothing
End Sub
 
Error 3022 is "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 the index to permit duplicate entries
and try again."

Assuming that pid is the primary key for your table, you need to change what
value you're passing to it.
 
Back
Top