472,328 Members | 1,107 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

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 2230
I tried this code but it doesn't seem to work, or have any effect
what-so-ever!

With CurrentDb.OpenRecordset("SnapshotTable")
.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, ExpectedCompletionDate " & _
"FROM tblJobs"
With rs
.Open sql, CurrentProject.AccessConnection, adOpenDynamic,
adLockOptimistic
.AddNew
!PercentComplete = CalculatedValue1
!ExpectedCompletionDate = CalculatedValue2
.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.OpenRecordset("SnapshotTable")
.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,
adLockOptimistic <----***
.AddNew
!ssDate = Date
!ssExpectedDate = Me.CompDate
!ssCompletion = Me.Completion
!ssAlgorithm = Algorithm
.Update
.Close
End With
If I included the ".AccessConection" 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, ExpectedCompletionDate " & _
"FROM tblJobs"
With rs
.Open sql, CurrentProject.AccessConnection, adOpenDynamic,
adLockOptimistic
.AddNew
!PercentComplete = CalculatedValue1
!ExpectedCompletionDate = CalculatedValue2
.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.AccessConnection, adOpenDynamic,
adLockOptimistic

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,
adLockOptimistic <----***
.AddNew
!ssDate = Date
!ssExpectedDate = Me.CompDate
!ssCompletion = Me.Completion
!ssAlgorithm = Algorithm
.Update
.Close
End With
If I included the ".AccessConection" 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, ExpectedCompletionDate " & _
"FROM tblJobs"
With rs
.Open sql, CurrentProject.AccessConnection, adOpenDynamic,
adLockOptimistic
.AddNew
!PercentComplete = CalculatedValue1
!ExpectedCompletionDate = CalculatedValue2
.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, adLockOptimistic

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, adLockOptimistic
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, adLockOptimistic
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, adLockOptimistic
Aug 9 '06 #10
2000

Nick 'The database Guy' wrote:
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, adLockOptimistic
Aug 9 '06 #11


Yes, in that case the syntax is slightly different. This syntax that I
gave you will only work on 2002 or better. Sorry.

James Hallam wrote:
2000

Nick 'The database Guy' wrote:
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, adLockOptimistic
Aug 9 '06 #12

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

Similar topics

3
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...
0
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...
1
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...
9
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...
2
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...
8
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...
6
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...
1
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...
10
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...
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

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.