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 » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How do I store a value from a form into a table?



 
 
Thread Tools Display Modes
  #1  
Old November 4th, 2005, 03:31 AM
A
external usenet poster
 
Posts: n/a
Default How do I store a value from a form into a table?

On my form I have a field that adds then displays the values of two previous
fields however the table is not updating this value. What should I do to
store the value in the table? I have the following syntax.
Sub AfterUpdate CalcTotPrice()
If IsNull(Me.FPrepaid) Or IsNull(Me.APrepaid) Then
Me.Prepaid = FPrepaid + APrepaid
End IF
End Sub

  #2  
Old November 4th, 2005, 04:37 AM
fredg
external usenet poster
 
Posts: n/a
Default How do I store a value from a form into a table?

On Thu, 3 Nov 2005 19:31:04 -0800, A wrote:

On my form I have a field that adds then displays the values of two previous
fields however the table is not updating this value. What should I do to
store the value in the table? I have the following syntax.
Sub AfterUpdate CalcTotPrice()
If IsNull(Me.FPrepaid) Or IsNull(Me.APrepaid) Then
Me.Prepaid = FPrepaid + APrepaid
End IF
End Sub


You shouldn't store that value.
You already have stored FPrepaid and APrepaid.
Any time you need to know the value of [Prepaid], re-compute it.
Storing derived (calculated) values goes against the rules of
relational database design.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #3  
Old November 4th, 2005, 01:27 PM
Jimmy Ionic
external usenet poster
 
Posts: n/a
Default How do I store a value from a form into a table?

You shouldn't store that value.
You already have stored FPrepaid and APrepaid.
Any time you need to know the value of [Prepaid], re-compute it.
Storing derived (calculated) values goes against the rules of
relational database design.

Right. But what if someone has thousands of records in a table? Do you
suggest to recalculate them each time when openning the base?
I have a similar question though. I got to add to each record in the table
two additional fields whose values are to be calculated on the base of the
other fields
from the same record (it is sort of a scoring procedure for the data). The
calculation procedure is very complicated. The question is what is the best
way of doing that? I don't want my operators to click on a button created
specially to run the scoring procedure. What I would like to do is to
calculate the values of these two fields as soon as operator finishes data
entry in a record via interface form.
  #4  
Old November 4th, 2005, 03:32 PM
fredg
external usenet poster
 
Posts: n/a
Default How do I store a value from a form into a table?

On Fri, 4 Nov 2005 05:27:05 -0800, Jimmy Ionic wrote:

You shouldn't store that value.
You already have stored FPrepaid and APrepaid.
Any time you need to know the value of [Prepaid], re-compute it.
Storing derived (calculated) values goes against the rules of
relational database design.

Right. But what if someone has thousands of records in a table? Do you
suggest to recalculate them each time when openning the base?
I have a similar question though. I got to add to each record in the table
two additional fields whose values are to be calculated on the base of the
other fields
from the same record (it is sort of a scoring procedure for the data). The
calculation procedure is very complicated. The question is what is the best
way of doing that? I don't want my operators to click on a button created
specially to run the scoring procedure. What I would like to do is to
calculate the values of these two fields as soon as operator finishes data
entry in a record via interface form.


It doesn't matter how many records you have. The answer is the same.
On the form used for data entry or data display, add an unbound
control. Set it's control source to something like:

=([FieldA] +[FieldB]) * .5 (or whatever your calculation should be).
This calculation gets done for each record as you navigate to that
record, not in advance. In a report, the calculation is done as it
comes up for printing/display.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #5  
Old November 4th, 2005, 05:51 PM
John Vinson
external usenet poster
 
Posts: n/a
Default How do I store a value from a form into a table?

On Fri, 4 Nov 2005 05:27:05 -0800, "Jimmy Ionic"
wrote:

You shouldn't store that value.
You already have stored FPrepaid and APrepaid.
Any time you need to know the value of [Prepaid], re-compute it.
Storing derived (calculated) values goes against the rules of
relational database design.

Right. But what if someone has thousands of records in a table? Do you
suggest to recalculate them each time when openning the base?


No. You recalculate each one individually as it's needed for display
on a Form or a Report. That's MUCH faster than a disk fetch.

I have a similar question though. I got to add to each record in the table
two additional fields whose values are to be calculated on the base of the
other fields
from the same record (it is sort of a scoring procedure for the data). The
calculation procedure is very complicated. The question is what is the best
way of doing that? I don't want my operators to click on a button created
specially to run the scoring procedure. What I would like to do is to
calculate the values of these two fields as soon as operator finishes data
entry in a record via interface form.


If you can DEMONSTRATE that a fast, modern CPU cannot calculate the
value fast enough for the user, then you can in fact store the value
into the table. It's a very bad idea, generally - once you have the
value stored, *it* can be edited, or any of the fields underlying the
value could be edited; you would then have a value in your table that
is *wrong*, with no easy way to detect that fact.

If you insist on doing so, though, knowing the danger: use the Form's
BeforeUpdate event. You'ld have one textbox displaying the calculated
expression (say from a VBA function), let's call it txtCalc; and
another textbox bound to the table field, txtStore. In the Form's
BeforeUpdate event put code like

If Not IsNull(Me!txtCalc) Then
Me!txtStore = Me!txtCalc
End If


John W. Vinson[MVP]
 




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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Move feild entries from form to form using global variables JackCGW General Discussion 11 November 14th, 2005 05:22 AM
Need Help In Printing Current Record in Specific Report RNUSZ@OKDPS Setting Up & Running Reports 1 May 16th, 2005 09:06 PM
Access combo box-show name, not ID, in table? write on New Users 30 April 30th, 2005 09:11 PM
Table Design A. Williams Database Design 3 April 29th, 2005 07:02 PM
dlookup miaplacidus Using Forms 9 August 5th, 2004 09:16 PM


All times are GMT +1. The time now is 09:26 AM.


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