Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / July 2007

Tip: Looking for answers? Try searching our database.

After update

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
an - 19 Jul 2007 13:00 GMT
Hi!

I have a form (based in T_Table) with a Start textbox (Date/Time field), a
Finish texbox (Date/Time field) and a 3rd textbox with =[Start]-[Finish] in
Control Source to show us the period between Start and Finish.

I would like help to after update put this result in my T_Table Period field.

Thanks in advance.
an
Al Campagna - 19 Jul 2007 13:26 GMT
An,
  In this case, you would not need to save the difference between the Start
and Finish.
  Since you have a Start and Finish saved to the table, you would just need
to recalculate the difference "on the fly" in any subsequent Form, Query, or
Report... just the way you did on the original form...
       = Start - Finish

  For example, if you had
      Price * Qty = LineTotal
you would not save the LineTotal, but reclaculate it from Price * Qty
whenever needed.

  As a general rule... don't save a value in a table that can be re-derived
from already saved values.

  Now... if you "must" save the difference, then add a field to your table
called, for example, [TimeDiff].  Place a text control on the form, with a
ControlSource of TimeDiff,  and use the AfterUpdate event of both Start and
Finish to trigger this code...

Private Sub Start_AfterUpdate()
   Me.TimeDiff = Start-Finish
End Sub
                    and...
Private Sub Finish_AfterUpdate()
   Me.TimeDiff = Start-Finish
End Sub

   If either Start or Finish change, the saved TimeDiff will be updated.

Signature

hth
   Al Campagna
   Access MVP 2007
   http://home.comcast.net/~cccsolutions/index.html

   "Find a job that you love, and you'll never work a day in your life."

> Hi!
>
[quoted text clipped - 8 lines]
> Thanks in advance.
> an
an - 19 Jul 2007 15:46 GMT
Al Campagna

Perfect!
Thank you very much for your good explanation!
Work fine.
an

> An,
>    In this case, you would not need to save the difference between the Start
[quoted text clipped - 39 lines]
> > Thanks in advance.
> > an
scubadiver - 19 Jul 2007 13:28 GMT
Why not make the [period] field the third text box? In the afterupdate event
in the "Finish" field write

Period = [finish] - [start]

Make the "period" field disabled and read only.

> Hi!
>
[quoted text clipped - 6 lines]
> Thanks in advance.
> an
an - 19 Jul 2007 14:18 GMT
Thanks for your reply.
  Apparently is a good idea but I don't know because don't work for me...
an

> Why not make the [period] field the third text box? In the afterupdate event
> in the "Finish" field write
[quoted text clipped - 13 lines]
> > Thanks in advance.
> > an
John W. Vinson - 19 Jul 2007 17:04 GMT
>Thanks for your reply.
>   Apparently is a good idea but I don't know because don't work for me...
>an

Please explain what you did and in what way it "don't work".

            John W. Vinson [MVP]
an - 19 Jul 2007 18:04 GMT
Didn't show us any result.
But already I have solution with Al Campagna method.
Thank you very much.
an

> >Thanks for your reply.
> >   Apparently is a good idea but I don't know because don't work for me...
[quoted text clipped - 3 lines]
>
>              John W. Vinson [MVP]
an - 19 Jul 2007 18:10 GMT
Sorry!

After compile DB work fine too.
an

> Why not make the [period] field the third text box? In the afterupdate event
> in the "Finish" field write
[quoted text clipped - 13 lines]
> > Thanks in advance.
> > an
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.