Not able to update a table in VBA Access code (1 Viewer)

Arasi

New member
Local time
Today, 12:34
Joined
Apr 15, 2009
Messages
1
Hi all,
I am a beginner in Access VBA.
I have an issue in updating a Table in the VBA code.

I am reading a text file in this VBA code and extracting the message IDs from the file and write some comment for the message ID.
I am trying to update the message ID and the comment to the Table "Result" using the below code. It is giving me Run time error - 3001. Invalid Argument.
it stops at the line Rslt.Updtae.
Dim db As Database
Dim Rslt As Recordset
Set db = CurrentDb()
Set Rslt = db.OpenRecordset("Result")
Rslt.AddNew
Rslt("Field1") = msg_id
Rslt("Field2") = comment
Rslt.Update

Please some one help me to overcome this. It was working fine before. Now its giving error. Donno where I ve gone wrong.

Thanks,
Arasi
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 08:04
Joined
Jul 9, 2003
Messages
16,278
try...

Dim db As DAO.Database
Dim Rslt As DAO.Recordset
Set db = CurrentDb()
Set Rslt = db.OpenRecordset("Result")
Rslt.AddNew
Rslt("Field1") = msg_id
Rslt("Field2") = comment
Rslt.Update
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 08:04
Joined
Jul 9, 2003
Messages
16,278
If your field "Field1" only allows Unique values, and you try it and add the same value again, then this can cause problems.
 

Users who are viewing this thread

Top Bottom