PC Review


Reply
Thread Tools Rate Thread

DSum Executing Too Late

 
 
Rob
Guest
Posts: n/a
 
      7th Dec 2006
I have had a problem for nearly a week now, and I am unable to decipher
it myself. The problem I am running in to, is that the DSum that my
button calls for, is not calculated until the current record (on a
continuous form) is defocused.

What I need is a way to force the DSum to update before the data is
sent to the table. I'm unsure of why it's not doing it currently, but
as it stands, the DSum will only visibly update on the form if I
defocus the current record.

Here is the code that I am using, any help would be greatly
appreciated.

------
Private Sub Command12_Click()
Dim rsCurr As DAO.Recordset
Dim strSQL As String
Dim nHours As Integer
Dim nMinutes As Integer
Dim nTotal As Date
Dim nXfer As Integer

Returned.Value = Time
nTotal = CheckedOut.Value - Returned.Value
nHours = DatePart("h", nTotal)
nMinutes = DatePart("n", nTotal)
nXfer = (nHours * 60) + nMinutes

TotalTime.Value = nXfer

TotalMinBox.Value = DSum("TotalTime", "LearnerActivity", "[IDNumber]="
& IDNumber)

strSQL = "SELECT TotalMinutes " & "FROM LearnerInformation " & "WHERE
IDNumber = " & Me.IDNumber
Set rsCurr = CurrentDb().OpenRecordset(strSQL)
If Not rsCurr.EOF Then
rsCurr.Edit
rsCurr![TotalMinutes] = TotalMinBox.Value
rsCurr.Update
End If

End Sub
--------

P.S., I did have a previous topic going where I posted this issue,
however the title was the name of the problem I had prior to this. I
hope reposting this as a more relevant term will not be troublesome.

Thanks again.

 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      7th Dec 2006
Why are you trying to store a calculated value? That's seldom a good thing
to do.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Rob" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have had a problem for nearly a week now, and I am unable to decipher
> it myself. The problem I am running in to, is that the DSum that my
> button calls for, is not calculated until the current record (on a
> continuous form) is defocused.
>
> What I need is a way to force the DSum to update before the data is
> sent to the table. I'm unsure of why it's not doing it currently, but
> as it stands, the DSum will only visibly update on the form if I
> defocus the current record.
>
> Here is the code that I am using, any help would be greatly
> appreciated.
>
> ------
> Private Sub Command12_Click()
> Dim rsCurr As DAO.Recordset
> Dim strSQL As String
> Dim nHours As Integer
> Dim nMinutes As Integer
> Dim nTotal As Date
> Dim nXfer As Integer
>
> Returned.Value = Time
> nTotal = CheckedOut.Value - Returned.Value
> nHours = DatePart("h", nTotal)
> nMinutes = DatePart("n", nTotal)
> nXfer = (nHours * 60) + nMinutes
>
> TotalTime.Value = nXfer
>
> TotalMinBox.Value = DSum("TotalTime", "LearnerActivity", "[IDNumber]="
> & IDNumber)
>
> strSQL = "SELECT TotalMinutes " & "FROM LearnerInformation " & "WHERE
> IDNumber = " & Me.IDNumber
> Set rsCurr = CurrentDb().OpenRecordset(strSQL)
> If Not rsCurr.EOF Then
> rsCurr.Edit
> rsCurr![TotalMinutes] = TotalMinBox.Value
> rsCurr.Update
> End If
>
> End Sub
> --------
>
> P.S., I did have a previous topic going where I posted this issue,
> however the title was the name of the problem I had prior to this. I
> hope reposting this as a more relevant term will not be troublesome.
>
> Thanks again.
>



 
Reply With Quote
 
Rob
Guest
Posts: n/a
 
      10th Dec 2006

I felt the need to store a calculated value because I felt like having
a calculated total of the hours spent logged in would be convenient for
future reports and/or just basic data browsing. I could have the total
just recalculated every time, but I have a fear that there will be a
time where I will need to have this data stored under the user's
profile, and I just wanted to cover my bases.



Douglas J. Steele wrote:
> Why are you trying to store a calculated value? That's seldom a good thing
> to do.
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Rob" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >I have had a problem for nearly a week now, and I am unable to decipher
> > it myself. The problem I am running in to, is that the DSum that my
> > button calls for, is not calculated until the current record (on a
> > continuous form) is defocused.
> >
> > What I need is a way to force the DSum to update before the data is
> > sent to the table. I'm unsure of why it's not doing it currently, but
> > as it stands, the DSum will only visibly update on the form if I
> > defocus the current record.
> >
> > Here is the code that I am using, any help would be greatly
> > appreciated.
> >
> > ------
> > Private Sub Command12_Click()
> > Dim rsCurr As DAO.Recordset
> > Dim strSQL As String
> > Dim nHours As Integer
> > Dim nMinutes As Integer
> > Dim nTotal As Date
> > Dim nXfer As Integer
> >
> > Returned.Value = Time
> > nTotal = CheckedOut.Value - Returned.Value
> > nHours = DatePart("h", nTotal)
> > nMinutes = DatePart("n", nTotal)
> > nXfer = (nHours * 60) + nMinutes
> >
> > TotalTime.Value = nXfer
> >
> > TotalMinBox.Value = DSum("TotalTime", "LearnerActivity", "[IDNumber]="
> > & IDNumber)
> >
> > strSQL = "SELECT TotalMinutes " & "FROM LearnerInformation " & "WHERE
> > IDNumber = " & Me.IDNumber
> > Set rsCurr = CurrentDb().OpenRecordset(strSQL)
> > If Not rsCurr.EOF Then
> > rsCurr.Edit
> > rsCurr![TotalMinutes] = TotalMinBox.Value
> > rsCurr.Update
> > End If
> >
> > End Sub
> > --------
> >
> > P.S., I did have a previous topic going where I posted this issue,
> > however the title was the name of the problem I had prior to this. I
> > hope reposting this as a more relevant term will not be troublesome.
> >
> > Thanks again.
> >


 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      10th Dec 2006
As fellow Access MVP John Vinson likes to say "Storing calculated data
generally accomplishes only three things: it wastes disk space, it wastes
time (a disk fetch is much slower than almost any reasonable calculation),
and it risks data validity, since once it's stored in a table either the
Total or one of the fields that goes into the total may be changed, making
the value WRONG."

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Rob" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> I felt the need to store a calculated value because I felt like having
> a calculated total of the hours spent logged in would be convenient for
> future reports and/or just basic data browsing. I could have the total
> just recalculated every time, but I have a fear that there will be a
> time where I will need to have this data stored under the user's
> profile, and I just wanted to cover my bases.
>
>
>
> Douglas J. Steele wrote:
>> Why are you trying to store a calculated value? That's seldom a good
>> thing
>> to do.
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no e-mails, please!)
>>
>>
>> "Rob" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> >I have had a problem for nearly a week now, and I am unable to decipher
>> > it myself. The problem I am running in to, is that the DSum that my
>> > button calls for, is not calculated until the current record (on a
>> > continuous form) is defocused.
>> >
>> > What I need is a way to force the DSum to update before the data is
>> > sent to the table. I'm unsure of why it's not doing it currently, but
>> > as it stands, the DSum will only visibly update on the form if I
>> > defocus the current record.
>> >
>> > Here is the code that I am using, any help would be greatly
>> > appreciated.
>> >
>> > ------
>> > Private Sub Command12_Click()
>> > Dim rsCurr As DAO.Recordset
>> > Dim strSQL As String
>> > Dim nHours As Integer
>> > Dim nMinutes As Integer
>> > Dim nTotal As Date
>> > Dim nXfer As Integer
>> >
>> > Returned.Value = Time
>> > nTotal = CheckedOut.Value - Returned.Value
>> > nHours = DatePart("h", nTotal)
>> > nMinutes = DatePart("n", nTotal)
>> > nXfer = (nHours * 60) + nMinutes
>> >
>> > TotalTime.Value = nXfer
>> >
>> > TotalMinBox.Value = DSum("TotalTime", "LearnerActivity", "[IDNumber]="
>> > & IDNumber)
>> >
>> > strSQL = "SELECT TotalMinutes " & "FROM LearnerInformation " & "WHERE
>> > IDNumber = " & Me.IDNumber
>> > Set rsCurr = CurrentDb().OpenRecordset(strSQL)
>> > If Not rsCurr.EOF Then
>> > rsCurr.Edit
>> > rsCurr![TotalMinutes] = TotalMinBox.Value
>> > rsCurr.Update
>> > End If
>> >
>> > End Sub
>> > --------
>> >
>> > P.S., I did have a previous topic going where I posted this issue,
>> > however the title was the name of the problem I had prior to this. I
>> > hope reposting this as a more relevant term will not be troublesome.
>> >
>> > Thanks again.
>> >

>



 
Reply With Quote
 
Rob
Guest
Posts: n/a
 
      10th Dec 2006
I see your points, and I will most likely be tweaking the operation of
this database before submitting it. However, the problem still remains
of the DSum not updating when the button is pressed. (Only when focus
is lost)

The people who will be using this application could very well be the
type of people who will become impatient and/or click-happy when they
hit submit, and nothing happens to the calculated total of minutes.

My biggest goal is to make this as simple as I can, since it is
replacing the office's existing software. Not all of the employees who
will be using this will understand that actions -are- in fact taking
place when the button is pressed, just not visible to them.

Thank you again for all of your assistance with my issues.


Douglas J. Steele wrote:
> As fellow Access MVP John Vinson likes to say "Storing calculated data
> generally accomplishes only three things: it wastes disk space, it wastes
> time (a disk fetch is much slower than almost any reasonable calculation),
> and it risks data validity, since once it's stored in a table either the
> Total or one of the fields that goes into the total may be changed, making
> the value WRONG."
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Rob" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >
> > I felt the need to store a calculated value because I felt like having
> > a calculated total of the hours spent logged in would be convenient for
> > future reports and/or just basic data browsing. I could have the total
> > just recalculated every time, but I have a fear that there will be a
> > time where I will need to have this data stored under the user's
> > profile, and I just wanted to cover my bases.
> >
> >
> >
> > Douglas J. Steele wrote:
> >> Why are you trying to store a calculated value? That's seldom a good
> >> thing
> >> to do.
> >>
> >> --
> >> Doug Steele, Microsoft Access MVP
> >> http://I.Am/DougSteele
> >> (no e-mails, please!)
> >>
> >>
> >> "Rob" <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >> >I have had a problem for nearly a week now, and I am unable to decipher
> >> > it myself. The problem I am running in to, is that the DSum that my
> >> > button calls for, is not calculated until the current record (on a
> >> > continuous form) is defocused.
> >> >
> >> > What I need is a way to force the DSum to update before the data is
> >> > sent to the table. I'm unsure of why it's not doing it currently, but
> >> > as it stands, the DSum will only visibly update on the form if I
> >> > defocus the current record.
> >> >
> >> > Here is the code that I am using, any help would be greatly
> >> > appreciated.
> >> >
> >> > ------
> >> > Private Sub Command12_Click()
> >> > Dim rsCurr As DAO.Recordset
> >> > Dim strSQL As String
> >> > Dim nHours As Integer
> >> > Dim nMinutes As Integer
> >> > Dim nTotal As Date
> >> > Dim nXfer As Integer
> >> >
> >> > Returned.Value = Time
> >> > nTotal = CheckedOut.Value - Returned.Value
> >> > nHours = DatePart("h", nTotal)
> >> > nMinutes = DatePart("n", nTotal)
> >> > nXfer = (nHours * 60) + nMinutes
> >> >
> >> > TotalTime.Value = nXfer
> >> >
> >> > TotalMinBox.Value = DSum("TotalTime", "LearnerActivity", "[IDNumber]="
> >> > & IDNumber)
> >> >
> >> > strSQL = "SELECT TotalMinutes " & "FROM LearnerInformation " & "WHERE
> >> > IDNumber = " & Me.IDNumber
> >> > Set rsCurr = CurrentDb().OpenRecordset(strSQL)
> >> > If Not rsCurr.EOF Then
> >> > rsCurr.Edit
> >> > rsCurr![TotalMinutes] = TotalMinBox.Value
> >> > rsCurr.Update
> >> > End If
> >> >
> >> > End Sub
> >> > --------
> >> >
> >> > P.S., I did have a previous topic going where I posted this issue,
> >> > however the title was the name of the problem I had prior to this. I
> >> > hope reposting this as a more relevant term will not be troublesome.
> >> >
> >> > Thanks again.
> >> >

> >


 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      10th Dec 2006
Since it's a bound text box, its value doesn't change until you leave the
control. Check the Help file for the difference between the Text and Value
properties of text boxes:

"While the control has the focus, the Text property contains the text data
currently in the control; the Value property contains the last saved data
for the control. When you move the focus to another control, the control's
data is updated, and the Value property is set to this new value. The Text
property setting is then unavailable until the control gets the focus again.
If you use the Save Record command on the Records menu to save the data in
the control without moving the focus, the Text property and Value property
settings will be the same."

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Rob" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I see your points, and I will most likely be tweaking the operation of
> this database before submitting it. However, the problem still remains
> of the DSum not updating when the button is pressed. (Only when focus
> is lost)
>
> The people who will be using this application could very well be the
> type of people who will become impatient and/or click-happy when they
> hit submit, and nothing happens to the calculated total of minutes.
>
> My biggest goal is to make this as simple as I can, since it is
> replacing the office's existing software. Not all of the employees who
> will be using this will understand that actions -are- in fact taking
> place when the button is pressed, just not visible to them.
>
> Thank you again for all of your assistance with my issues.
>
>
> Douglas J. Steele wrote:
>> As fellow Access MVP John Vinson likes to say "Storing calculated data
>> generally accomplishes only three things: it wastes disk space, it wastes
>> time (a disk fetch is much slower than almost any reasonable
>> calculation),
>> and it risks data validity, since once it's stored in a table either the
>> Total or one of the fields that goes into the total may be changed,
>> making
>> the value WRONG."
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no private e-mails, please)
>>
>>
>> "Rob" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> >
>> > I felt the need to store a calculated value because I felt like having
>> > a calculated total of the hours spent logged in would be convenient for
>> > future reports and/or just basic data browsing. I could have the total
>> > just recalculated every time, but I have a fear that there will be a
>> > time where I will need to have this data stored under the user's
>> > profile, and I just wanted to cover my bases.
>> >
>> >
>> >
>> > Douglas J. Steele wrote:
>> >> Why are you trying to store a calculated value? That's seldom a good
>> >> thing
>> >> to do.
>> >>
>> >> --
>> >> Doug Steele, Microsoft Access MVP
>> >> http://I.Am/DougSteele
>> >> (no e-mails, please!)
>> >>
>> >>
>> >> "Rob" <(E-Mail Removed)> wrote in message
>> >> news:(E-Mail Removed)...
>> >> >I have had a problem for nearly a week now, and I am unable to
>> >> >decipher
>> >> > it myself. The problem I am running in to, is that the DSum that my
>> >> > button calls for, is not calculated until the current record (on a
>> >> > continuous form) is defocused.
>> >> >
>> >> > What I need is a way to force the DSum to update before the data is
>> >> > sent to the table. I'm unsure of why it's not doing it currently,
>> >> > but
>> >> > as it stands, the DSum will only visibly update on the form if I
>> >> > defocus the current record.
>> >> >
>> >> > Here is the code that I am using, any help would be greatly
>> >> > appreciated.
>> >> >
>> >> > ------
>> >> > Private Sub Command12_Click()
>> >> > Dim rsCurr As DAO.Recordset
>> >> > Dim strSQL As String
>> >> > Dim nHours As Integer
>> >> > Dim nMinutes As Integer
>> >> > Dim nTotal As Date
>> >> > Dim nXfer As Integer
>> >> >
>> >> > Returned.Value = Time
>> >> > nTotal = CheckedOut.Value - Returned.Value
>> >> > nHours = DatePart("h", nTotal)
>> >> > nMinutes = DatePart("n", nTotal)
>> >> > nXfer = (nHours * 60) + nMinutes
>> >> >
>> >> > TotalTime.Value = nXfer
>> >> >
>> >> > TotalMinBox.Value = DSum("TotalTime", "LearnerActivity",
>> >> > "[IDNumber]="
>> >> > & IDNumber)
>> >> >
>> >> > strSQL = "SELECT TotalMinutes " & "FROM LearnerInformation " &
>> >> > "WHERE
>> >> > IDNumber = " & Me.IDNumber
>> >> > Set rsCurr = CurrentDb().OpenRecordset(strSQL)
>> >> > If Not rsCurr.EOF Then
>> >> > rsCurr.Edit
>> >> > rsCurr![TotalMinutes] = TotalMinBox.Value
>> >> > rsCurr.Update
>> >> > End If
>> >> >
>> >> > End Sub
>> >> > --------
>> >> >
>> >> > P.S., I did have a previous topic going where I posted this issue,
>> >> > however the title was the name of the problem I had prior to this. I
>> >> > hope reposting this as a more relevant term will not be troublesome.
>> >> >
>> >> > Thanks again.
>> >> >
>> >

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A Bit Late :) CSB Introductions 11 30th Oct 2006 09:47 PM
Late Binding or Late Anything Piranha Microsoft Excel Programming 4 15th Oct 2005 03:42 AM
can a late bound delegate be called in a late bound C# dll? Daniel Microsoft C# .NET 1 17th Dec 2004 05:38 AM
Re: stop calculating late fees once rent+late fee met Bernie Deitrick Microsoft Excel Misc 0 27th Jul 2004 02:07 PM
Query to Calculate a late payment for each 30 days late MMJII Microsoft Access Queries 5 30th Dec 2003 07:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:35 PM.