PC Review


Reply
Thread Tools Rate Thread

How to change existing table record value by VBA and How to add newrecord in existing table by VBA

 
 
K
Guest
Posts: n/a
 
      18th May 2010
Hi all, I got table in my database with name "tbldata" and i have two
fields in that table with the name "Ticket_No" and "Amount". In
"Ticket_No" filed column i have value "SD001" and in same row of
"Amount" column i have figure "50". With VBA how can i lookup for
value "SD001" in "Ticket_No" field and change figure "50" to "30"
which is appearing in same row of "Amount" column field. My other
question is that how can i add new record in same table with VBA. I
want to put new value "VR004" in "Ticket_No" field column and new
figure "20" in same row of "Amount" column. I'll be very greatful if
any friend can help me with simple vba code on this.
 
Reply With Quote
 
 
 
 
XPS35
Guest
Posts: n/a
 
      18th May 2010
K wrote:

>
> Hi all, I got table in my database with name "tbldata" and i have two
> fields in that table with the name "Ticket_No" and "Amount". In
> "Ticket_No" filed column i have value "SD001" and in same row of
> "Amount" column i have figure "50". With VBA how can i lookup for
> value "SD001" in "Ticket_No" field and change figure "50" to "30"
> which is appearing in same row of "Amount" column field. My other
> question is that how can i add new record in same table with VBA. I
> want to put new value "VR004" in "Ticket_No" field column and new
> figure "20" in same row of "Amount" column. I'll be very greatful if
> any friend can help me with simple vba code on this.


The code for the update is:
DoCmd.RunSQL "Update tbldata SET Amount=30 WHERE Ticket_No='SD001'"

And for adding a rcord:
DoCmd.RunSQL "INSERT INTO tbldata(Ticket_No,Amount) VALUES('VR004',20)"

--
Groeten,

Peter
http://access.xps350.com

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change existing table record value by VBA and How to add newrecord in existing table by VBA K Microsoft Access Form Coding 1 18th May 2010 09:54 AM
SQL - Checking for existing record in table troubledstudent Microsoft Access Form Coding 3 13th Feb 2008 12:12 AM
how to add an existing record to another table =?Utf-8?B?SmFtZXM=?= Microsoft Access Forms 1 7th Sep 2006 05:57 AM
Importing to existing table but any existing record need to be upd =?Utf-8?B?ZGNvcmVudGlu?= Microsoft Access External Data 0 15th May 2006 11:32 AM
Add Record To Existing Table via VB code =?Utf-8?B?Uk5VU1pAT0tEUFM=?= Microsoft Access Form Coding 1 20th May 2005 02:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:26 PM.