Wrox Programmer Forums
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 8th, 2007, 02:44 PM
Registered User
Join Date: Jan 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Update Table From Form

I've got a calculated value on a form that I want to save into a table. Other than writing VB Code to do SQL commands, is there a direct way to do it in the form?

Thanks in advance
Old January 9th, 2007, 08:45 AM
Friend of Wrox
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts

If the form is bound, then you just do the calculation on the Before Insert and Before Update event of the form. It is generally not a good idea to store calculated values, however, there are times when it is beneficial, as when the variables may change and you want the value actually charged a customer using the then current value.

That being said, do something like this:

Dim iQuantity As Integer
Dim lPrice, lTotal As Long

iQuantity = Me.Quantity
lPrice = Me.Price

lTotal = iQuantity * lPrice

Me.Total = lTotal

Did that work?

Old January 9th, 2007, 01:49 PM
Registered User
Join Date: Jan 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks mmcdonal

I don't have a chance to try it right now, but I will in a few days. From your sample code, it looks like I can update data in the table without doing SQL, just by referring to the bound table as "Me."? I'm used to doing databases through SQL commands only using a different programming language, so I'm trying to figure out how best to do it in the integrated environment.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Update one table to another table using DTS in SQL Printmaker SQL Language 0 July 24th, 2007 07:17 AM
Update table using SQL query from form pater53 Access VBA 4 January 24th, 2007 11:24 AM
Update parent table with the sum of child table gbrown SQL Language 2 November 9th, 2004 07:53 AM
Update table from form leeloo Access VBA 1 June 28th, 2004 11:50 AM
Access update table from form values trevander Access VBA 2 April 28th, 2004 03:06 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.