Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 8th, 2007, 02:44 PM
Registered User
 
Join Date: Jan 2007
Location: , , .
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
Reply With Quote
  #2 (permalink)  
Old January 9th, 2007, 08:45 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

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?


mmcdonal
Reply With Quote
  #3 (permalink)  
Old January 9th, 2007, 01:49 PM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.



Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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


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



All times are GMT -4. The time now is 01:11 PM.


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