Not able to update a table in VBA Access code
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.Update.
Code:
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
Re: Not able to update a table in VBA Access code
Quote:
Rslt("Field1") = msg_id
Rslt("Field2") = comment
Are any of the fields that you are using above of "AutoNumber" type?
Re: Not able to update a table in VBA Access code
No both are of type text.
Re: Not able to update a table in VBA Access code
Can you remark out one of the update lines:
Code:
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 '<< commented out
Rslt.Update
set rslt = nothing
try to run to see if it is one of the data fields you are passing that is not right.
Also press ctrl+g and type:
then press return... does that print out the two data items correctly?