Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 04-15-2009, 04:17 AM   #1
Arasi
Registered User
 
Join Date: Apr 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Arasi is on a distinguished road
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.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

Arasi is offline   Reply With Quote
Old 04-15-2009, 04:27 AM   #2
Uncle Gizmo
Nifty Access Guy
 
Uncle Gizmo's Avatar
 
Join Date: Jul 2003
Location: Newbury Berks UK
Posts: 8,605
Thanks: 238
Thanked 636 Times in 607 Posts
Uncle Gizmo has a spectacular aura about Uncle Gizmo has a spectacular aura about Uncle Gizmo has a spectacular aura about
Send a message via Skype™ to Uncle Gizmo
Re: Not able to update a table in VBA Access code

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
__________________
............

Answering questions on AWF has given me an insight into the difficulties in programming with MS Access. Often, idea's for my YouTube video's originate from this experience. My forte is in presenting the solution in video format. Please take this opportunity to join My YouTube channel ---
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Uncle Gizmo is offline   Reply With Quote
Old 04-15-2009, 04:28 AM   #3
Uncle Gizmo
Nifty Access Guy
 
Uncle Gizmo's Avatar
 
Join Date: Jul 2003
Location: Newbury Berks UK
Posts: 8,605
Thanks: 238
Thanked 636 Times in 607 Posts
Uncle Gizmo has a spectacular aura about Uncle Gizmo has a spectacular aura about Uncle Gizmo has a spectacular aura about
Send a message via Skype™ to Uncle Gizmo
Re: Not able to update a table in VBA Access code

If your field "Field1" only allows Unique values, and you try it and add the same value again, then this can cause problems.

__________________
............

Answering questions on AWF has given me an insight into the difficulties in programming with MS Access. Often, idea's for my YouTube video's originate from this experience. My forte is in presenting the solution in video format. Please take this opportunity to join My YouTube channel ---
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Uncle Gizmo is offline   Reply With Quote
Reply

Tags
access , vba

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Access Excel VBA code from MS Access llkhoutx Excel 0 07-24-2008 04:02 AM
create a progress bar in VB JohnLee Modules & VBA 3 01-08-2008 07:29 AM
way too many tables qwertyjjj Theory and practice of database design 3 08-01-2007 01:04 PM
Can i insert VBA code into an XLS exported from Access? simon_marklar Modules & VBA 2 08-23-2005 06:50 PM




All times are GMT -8. The time now is 08:43 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World