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 11 2315
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.)
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
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.)
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
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
It decided to work when using the following code, cheers for the help!
rs.Open sql, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
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
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
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
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
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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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.
...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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,...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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...
|
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...
| |