|
-
Apr 15th, 2009, 07:02 AM
#1
Thread Starter
New Member
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
Last edited by Arasi; Apr 15th, 2009 at 07:28 AM.
-
Apr 15th, 2009, 03:37 PM
#2
Re: Not able to update a table in VBA Access code
Rslt("Field1") = msg_id
Rslt("Field2") = comment
Are any of the fields that you are using above of "AutoNumber" type?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Apr 16th, 2009, 12:19 AM
#3
Thread Starter
New Member
Re: Not able to update a table in VBA Access code
No both are of type text.
-
Apr 20th, 2009, 06:36 AM
#4
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?
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|