PDA

View Full Version : i wnat helpe in thise code ;cant update record



malkasoft10
08-12-2006, 02:54 AM
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

OBP
08-13-2006, 12:13 PM
What is the run time Error Description?

Imdabaum
08-14-2006, 10:03 AM
Don't update the rs.pid.


You are already using that primary key id. So by setting it to itself it is causing the duplilcate primary key error. Hope that helps, if you need more specifics view your previous post.:friends:

Imdabaum
08-15-2006, 07:25 AM
Sorry I didn't see this before, what is happening is in your save Modify button. You open the record set but you aren't locating the record in that set.

Try inserting this before your rs.Edit statement in Command62 I believe. which ever is called by the Save Modify button. Without this code your recordset gets opened to the first record automatically and updates it.

rs.FindFirst ("[id] = " & [Forms]![In]![id])

malkasoft10
08-15-2006, 10:57 PM
:bow: :beerchug: i would like to thank all members whom helpe my problem and i hope all best wishs for you

all my respect an apreciate for you

malkasoft10
08-15-2006, 10:59 PM
all my respect mr :Imdabaum thank you it solve the problem

Imdabaum
08-16-2006, 09:44 AM
Glad I could help remember. Sorry I didn't notice that correction the first time.

Remember next time that you don't have to post a new topic for each reply.