After update

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.

--
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."
 
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.
 
Thanks for your reply.
Apparently is a good idea but I don't know because don't work for me...
an

scubadiver said:
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.

an said:
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

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

Al Campagna said:
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.

--
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."



an said:
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
 
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]
 
Didn't show us any result.
But already I have solution with Al Campagna method.
Thank you very much.
an
 
Sorry!

After compile DB work fine too.
an

scubadiver said:
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.

an said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

= versus > or < 12
Show null values in Query 0
DSum ? 9
Automatically requery 1
Refresh unbound textbox 5
Access 2010 Observation 3
cascading combo - record count 1
Date Range Query Problem 20

Back
Top