473,708 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Storing calculated values... Exception!

I have read through all the past topics and couldn't find what I was
after so...

I am looking to store some calculated values (don't flame just yet,
just read on!). I have an piece of code behind a form which calculates
a percentage completion and an expected completion date of a job. I
would like to store this information in a separate table, along with
the actual date the values were calculated.

Whenever a job is completed I can see how far off my estimated
completion date is off the actual date and make any changes neccessary.

Within the code there are a few different algorithms used to calculate
the estimated completion date, so I would need to store this value as
well.

So Questions...
* Is this a valid exception to the "never store calculted values"
* Would the best idea be to use an append query?
If so could someone post the base code as I am not too hot with SQL!

Cheers,

James Hallam

Aug 8 '06 #1
11 2354
I tried this code but it doesn't seem to work, or have any effect
what-so-ever!

With CurrentDb.OpenR ecordset("Snaps hotTable")
.AddNew
!ssstgKey = Me.stgKey
!ssDate = Date
!ssExpectedDate = Me.CompDate
!ssCompletion = Me.Completion
!ssAlgorithm = Algorithm
End With

(Where stg, CompDate, Completion are textboxs on the form; Date is
(hopefully) the current date; and algorithm is a variable defined in
the form.)

Aug 8 '06 #2
Hi James,

This is a valid reason, I my opinion, for storing the calculated value.
I also think that you would be better off using VBA write them to the
table.

Dim rs As New ADODB.Recordset
Dim sql As String
sql = _
"SELECT JobID, PercentComplete , ExpectedComplet ionDate " & _
"FROM tblJobs"
With rs
.Open sql, CurrentProject. AccessConnectio n, adOpenDynamic,
adLockOptimisti c
.AddNew
!PercentComplet e = CalculatedValue 1
!ExpectedComple tionDate = CalculatedValue 2
.Update
.Close
End With

Your VBA should look something like this.

Good luck

Nick
James Hallam wrote:
I have read through all the past topics and couldn't find what I was
after so...

I am looking to store some calculated values (don't flame just yet,
just read on!). I have an piece of code behind a form which calculates
a percentage completion and an expected completion date of a job. I
would like to store this information in a separate table, along with
the actual date the values were calculated.

Whenever a job is completed I can see how far off my estimated
completion date is off the actual date and make any changes neccessary.

Within the code there are a few different algorithms used to calculate
the estimated completion date, so I would need to store this value as
well.

So Questions...
* Is this a valid exception to the "never store calculted values"
* Would the best idea be to use an append query?
If so could someone post the base code as I am not too hot with SQL!

Cheers,

James Hallam
Aug 8 '06 #3
You have to update a recordset for the values to be saved, please see
my earlier example.

Good luck

Nick

James Hallam wrote:
I tried this code but it doesn't seem to work, or have any effect
what-so-ever!

With CurrentDb.OpenR ecordset("Snaps hotTable")
.AddNew
!ssstgKey = Me.stgKey
!ssDate = Date
!ssExpectedDate = Me.CompDate
!ssCompletion = Me.Completion
!ssAlgorithm = Algorithm
End With

(Where stg, CompDate, Completion are textboxs on the form; Date is
(hopefully) the current date; and algorithm is a variable defined in
the form.)
Aug 8 '06 #4
i tried you code but still no result...

Dim rs As New ADODB.Recordset
Dim sql As String
sql = "SELECT ssDate, ssExpectedDate, ssCompletion, ssAlgorithm
FROM SnapshotTable"
With rs
***--- .Open sql, CurrentProject, adOpenDynamic,
adLockOptimisti c <----***
.AddNew
!ssDate = Date
!ssExpectedDate = Me.CompDate
!ssCompletion = Me.Completion
!ssAlgorithm = Algorithm
.Update
.Close
End With
If I included the ".AccessConecti on" on line 6 it didn't like it, not
recognising object.
The code above it fails on line 6, saying the arguments are in conflict
with one another. I'm sure this code will work... just a minor error
with that one line?
Nick 'The database Guy' wrote:
Hi James,

This is a valid reason, I my opinion, for storing the calculated value.
I also think that you would be better off using VBA write them to the
table.

Dim rs As New ADODB.Recordset
Dim sql As String
sql = _
"SELECT JobID, PercentComplete , ExpectedComplet ionDate " & _
"FROM tblJobs"
With rs
.Open sql, CurrentProject. AccessConnectio n, adOpenDynamic,
adLockOptimisti c
.AddNew
!PercentComplet e = CalculatedValue 1
!ExpectedComple tionDate = CalculatedValue 2
.Update
.Close
End With

Your VBA should look something like this.

Good luck

Nick
James Hallam wrote:
I have read through all the past topics and couldn't find what I was
after so...

I am looking to store some calculated values (don't flame just yet,
just read on!). I have an piece of code behind a form which calculates
a percentage completion and an expected completion date of a job. I
would like to store this information in a separate table, along with
the actual date the values were calculated.

Whenever a job is completed I can see how far off my estimated
completion date is off the actual date and make any changes neccessary.

Within the code there are a few different algorithms used to calculate
the estimated completion date, so I would need to store this value as
well.

So Questions...
* Is this a valid exception to the "never store calculted values"
* Would the best idea be to use an append query?
If so could someone post the base code as I am not too hot with SQL!

Cheers,

James Hallam
Aug 8 '06 #5
This is the right code to use.

rs.Open sql, CurrentProject. AccessConnectio n, adOpenDynamic,
adLockOptimisti c

However you must already have declared rs as a new adodb recordset, you
do so with the line of code:

Dim rs As New adodb.Recordset

It works for me every time!

Nick

James Hallam wrote:
i tried you code but still no result...

Dim rs As New ADODB.Recordset
Dim sql As String
sql = "SELECT ssDate, ssExpectedDate, ssCompletion, ssAlgorithm
FROM SnapshotTable"
With rs
***--- .Open sql, CurrentProject, adOpenDynamic,
adLockOptimisti c <----***
.AddNew
!ssDate = Date
!ssExpectedDate = Me.CompDate
!ssCompletion = Me.Completion
!ssAlgorithm = Algorithm
.Update
.Close
End With
If I included the ".AccessConecti on" on line 6 it didn't like it, not
recognising object.
The code above it fails on line 6, saying the arguments are in conflict
with one another. I'm sure this code will work... just a minor error
with that one line?
Nick 'The database Guy' wrote:
Hi James,

This is a valid reason, I my opinion, for storing the calculated value.
I also think that you would be better off using VBA write them to the
table.

Dim rs As New ADODB.Recordset
Dim sql As String
sql = _
"SELECT JobID, PercentComplete , ExpectedComplet ionDate " & _
"FROM tblJobs"
With rs
.Open sql, CurrentProject. AccessConnectio n, adOpenDynamic,
adLockOptimisti c
.AddNew
!PercentComplet e = CalculatedValue 1
!ExpectedComple tionDate = CalculatedValue 2
.Update
.Close
End With

Your VBA should look something like this.

Good luck

Nick
James Hallam wrote:
I have read through all the past topics and couldn't find what I was
after so...
>
I am looking to store some calculated values (don't flame just yet,
just read on!). I have an piece of code behind a form which calculates
a percentage completion and an expected completion date of a job. I
would like to store this information in a separate table, along with
the actual date the values were calculated.
>
Whenever a job is completed I can see how far off my estimated
completion date is off the actual date and make any changes neccessary.
>
Within the code there are a few different algorithms used to calculate
the estimated completion date, so I would need to store this value as
well.
>
So Questions...
* Is this a valid exception to the "never store calculted values"
* Would the best idea be to use an append query?
If so could someone post the base code as I am not too hot with SQL!
>
Cheers,
>
James Hallam
Aug 8 '06 #6
It decided to work when using the following code, cheers for the help!

rs.Open sql, CurrentProject. Connection, adOpenDynamic, adLockOptimisti c

Aug 9 '06 #7
What is your backend database?

Nick
James Hallam wrote:
It decided to work when using the following code, cheers for the help!

rs.Open sql, CurrentProject. Connection, adOpenDynamic, adLockOptimisti c
Aug 9 '06 #8
my frontend is called prototypev4.mdb , backend is called DataV1.mdb
Nick 'The database Guy' wrote:
What is your backend database?

Nick
James Hallam wrote:
It decided to work when using the following code, cheers for the help!

rs.Open sql, CurrentProject. Connection, adOpenDynamic, adLockOptimisti c
Aug 9 '06 #9
I was wondering why the CurrentProject. AccessConection usn't working.
Which version of Access are you using?

Nick

James Hallam wrote:
my frontend is called prototypev4.mdb , backend is called DataV1.mdb
Nick 'The database Guy' wrote:
What is your backend database?

Nick
James Hallam wrote:
It decided to work when using the following code, cheers for the help!
>
rs.Open sql, CurrentProject. Connection, adOpenDynamic, adLockOptimisti c
Aug 9 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
843
by: Stefanos | last post by:
Hi everybody, I need some help on calculated values in my database design. I'm creating an accounting / business management application with the usual modules like A/R, A/P, Inventory, etc. I don't know how to handle calculated values in fields like "Customer Balance", "Inventory Item Qty on Hand", "Inventory Item Qty Last cost" and other similar.
0
2075
by: Henry | last post by:
Hi Is there any good ideas how to update form vb code always after some values are changed / added by vb (not user). I have some code behind subforms vb and there are calculations behind "Form_Current" section those I need to re-calculate after some values are changed or added. The problem is that if list box value is calculated in vb, access wont
1
2181
by: douh | last post by:
I know that this is not the way, however I need to save certian calculated values so that they do not change over time, ie. new tax rates etc. This is for an invoice header and invoice subform. I have a form myheader and mysub that are linked via a invoice number. mysub calculates qty * list = extprice. I am summing these into a sum_ext field in mysub footer. I need to have this value updated into the myheader invsubtot. I have tried many...
9
1297
by: Crirus | last post by:
I have ~200 players on a server... They share the same 512x512 tiles map... Each player have an explored area and a visible area... visible area is given by players's current units and buildings... Now, I'm facing with the problem of how to store does areas... One way is to keep a explored(512,512) array of booleans... each explored(i,j)=True mean player explored the tile on (i.j)... the same for visible...
2
2143
by: Zlatko Matiæ | last post by:
I have a field and want to have a calculated field in a report that counts it. It had control source set to "=count (). As can be also Null, I would like it to count only values distinct from Null. I tried by "Control Source=Count( Is Not Null), but it doesn't work, it still counts all rows, even with Null. How to set Control Source in the calcualted text box, in order to count only values that are not null? Thanks,
8
2183
by: TORQUE | last post by:
Hi, I am having some trouble with recording a field on a form into my Table after formatting it to calculate several fields on the form. If i just put the amount in the field and have it linked to the correct field in my Table, it will record it. But not the other if I have the field Total several others first. Where am I going wrong? TIA TORQUE
6
5851
by: yasodhai | last post by:
Hi, I used a dropdown control which is binded to a datagrid control. I passed the values to the dropdownlist from the database using a function as follows in the aspx itself. <asp:DropDownList ID="FldType_add" Runat="server" DataSource='< %#GetFieldType()%>' DataValueField="Type" DataTextField="Type" /> Oce the page is loaded all the values are added to the dropdown list. But when I thought of getting the selected value from the...
1
2082
by: Prashantsd | last post by:
Hi, I have problem storing the calculated value in table. I have a text box(Ranking) which display the sum of 4 combo box. this is wat I hav done in control source of tex box = + + + I want this value to be stored in table, could you please help me to do this in simple way. Thanks in advance Prash
10
3623
by: drago | last post by:
Hello guys again! Back with invoice problems. Just want to know how to store data in the main database in different tables and fields using a form. I have a datasheet view of a form where i have to show ; invoice number (INPUT) price (INPUT) No. of units (INPUT), Weekly Total (calculated by =*) start date (INPUT)...
0
8787
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9289
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9158
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7921
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5939
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4454
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2508
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.