A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

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



 
 
Thread Tools Display Modes
  #1  
Old May 18th, 2010, 09:08 AM posted to microsoft.public.access.tablesdbdesign
K[_4_]
external usenet poster
 
Posts: 25
Default How to change existing table record value by VBA and How to add newrecord in existing table by VBA

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.
  #2  
Old May 18th, 2010, 09:20 AM posted to microsoft.public.access.tablesdbdesign
xps35
external usenet poster
 
Posts: 22
Default How to change existing table record value by VBA and How to add new

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

 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:32 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.