Timestamp

B

Beeyen

Good Day All,

For the purpose of tracking changing in the my form I have added a timestamp
with fields called Time_In and Time_Out (where Time Out should populate when
the status drop-down is completed) I would like the Time_In to populate
automatically when the form opens. Could someone share coding as to how best
to accomplish this?

Thanks
 
B

Beeyen

Thank you Mr. Campagna, for the quick response! As per your suggestion, I
have changed the coding for TimeIn from GotFocus to OnCurrent event. Should
I change the position of coding for the TimeOut, note my coding as follows:

Private Sub Time_Out_AfterUpdate()
If Me.Status = "Complete" Then
Me.Time_Out = Now()
End If
End Sub

Also will the code for the TimeIn date/time change whenever I enter the form
or only when I make a change and save?

Let me know and thanks again!
 
A

a a r o n . k e m p f

SQL Server and mySql has native timestamps. Access doesnt' support
this functionality; because Access isn't a real database.

Furthermore, you could do anyhting like this-- that you wanted to do--
with a trigger.

I just don't think that writing the same piece of code in 40 different
text boxes-- I just don't think that sounds like fun.

-Aaron
 
G

George

Interestingly enough, the Current event is a fom level event, not a control
level event, so it fires once, on each current record, not on 40 different
controls on a form. Therefore, writing it ONCE in the form's Current event
is all that is required.

Equally interesting is that the poster only mentions a single control (the
TimeOut field) , not 40 different controls on a form.

Of course, it is also true that your answer could have been relavant to a
question about time stamps in SQL Server tables or to triggers, had either
of those been the actual question presented.

Please try to focus. It's not that hard to do. If you do want to have a
positive infleunce on others, you need to be able to project a coherent,
cogent presence.


message
SQL Server and mySql has native timestamps. Access doesnt' support
this functionality; because Access isn't a real database.

Furthermore, you could do anyhting like this-- that you wanted to do--
with a trigger.

I just don't think that writing the same piece of code in 40 different
text boxes-- I just don't think that sounds like fun.

-Aaron
 
A

a a r o n . k e m p f

So-- what you're trying to tell me.. is that a trigger would not solve
this easily?

that SQL Server timestamps wouldn't do most of what they needed--
without any coding?

That mySql timestamps would do _EXACTLY_ what they need.. without
writing any code?

Why code it in 40 different controls... SQL Server; it would have been
'done already'.

I don't need to focus.
This is my newsgroup. SQL Server is the optimal engine for MS
Access.

If you want to talk otherwise; go to
microsoft.public.access.JetFormatIsObsoleteAndItIsForLosers

-Aaron
 
A

a a r o n . k e m p f

Equally interesting... is that the poster is asking for FORM_OPEN not
FORM_CURRENT

kinda funny that nobody caught that either ;)

I'll try to stay on topic.

But I will not put up with organized, perpetual calpaign of
misinformation about SQL Server.
It's like these jerk-offs all get paid for Larry Ellison or
something.. Either that or they're just sleeping with Larry. ;)

-Aaron
 
B

BruceM

Actually, it was "when the form opens", which really cannot be taken as a
specific question about the form's Open event. In any case, the Open event
is too soon to be writing to a record.
BTW, emoticons have their place, but a representation of a wink does not
mitigate ugly jabs at people.

message
Equally interesting... is that the poster is asking for FORM_OPEN not
FORM_CURRENT

kinda funny that nobody caught that either ;)

I'll try to stay on topic.

But I will not put up with organized, perpetual calpaign of
misinformation about SQL Server.
It's like these jerk-offs all get paid for Larry Ellison or
something.. Either that or they're just sleeping with Larry. ;)

-Aaron
 
A

Al Campagna

Beeyen,
Unfortunately, when you start to edit a record, you could use the
BeforeUpdate event of the form to set a time (Now), but... that time will
only enter when the record is fianlly updated (written to the table)... and
that time will be "at that instant"... not when the BeforeUpdate initially
fired.
So we have to be a bit sneaky.

Try this...
We'll need 3 fields, LastEditStart, LastEditEnd, and TempEditStart.

When the form is Current...
Private Sub Form_Current()
TempStartEdit = Now
End Sub
That "captures" the time the record is initially accessed.

On the AfterUpdate of the Form... (when changes are written...if at all)
Private Sub Form_AfterUpdate()
LastEditStart = TempStartEdit
LastEditEnd = Now()
End If

If the record is not edited, this code will not run, and any previous
values should remain in effect

Now this is not perfect, and you must be sure that no Update, or
Refresh, or Requery occurs "during" the editing process. That would fire
the AfterUpdate of the form prematurely, and give an incorrect LastEditEnd.
Perhaps though... this might be sufficient for your needs.
If you find this does not meet your needs, we have other solutions
(requiring a bit more coding).
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

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

a a r o n . k e m p f

I'm sorry.. so 'when the form opens' cant be treated as 'when the form
opens'?

I'm not sure that the open event is too soon to be writing to a
record.
That is what the OP is asking for.

And likewise-- personal attacks are all fine and good.. but you're
_WRONG_ in this post, kid.. Give it up.. You don't need to attack me
nonstop. Because I am not a baby db kid like you.

Thanks ;)

-Aaron
 
B

BruceM

Maybe the Before Insert event to set TempEditStart, so that it is set only
when the user actually starts to type something (if I understand the Before
Insert event correctly)?

I would be inclined to set a date variable to Now rather than writing to a
field that exists only to store a variable.

Maybe I don't fully understand After Update, but it seems to me that if a
field is updated in the After Update event (assuming that is possible), then
the form is dirtied, so the Before Update and After Update events run again,
and there will be an updating loop. I would have expected the fields to be
set at the end of the Before Update event (at the end so validation, if any,
can occur, and the event can be cancelled if there is a problem).

Regarding a save occurring during the editing process, if the record is
edited further the Before Update event will run again, so I'm not sure that
is necessarily a problem. However, a potential problem may be that if the
user leaves a record mid-edit, then returns to it, LastEditStart will be
reset. Perhaps an Editing Complete command button could set a Boolean and
save the record. If the Boolean is false the Before Update event could
generate a message box asking the user if the edit is complete, and a No
response could cancel the update. If it is true, no message. In any case,
re-set the Boolean in the Before Update event.
 
A

a a r o n . k e m p f

Whatever Tony.

This silly kid is attacking me -- for no reason-- when I am the one
that is right in this thread.
--------------------------
Actually, it was "when the form opens", which really cannot be taken
as a
specific question about the form's Open event. In any case, the Open
event
is too soon to be writing to a record.
BTW, emoticons have their place, but a representation of a wink does
not
mitigate ugly jabs at people.
--------------------------

Do you think that 'when the form opens' can be interpreted as the
forms Open event?

I call hogwash; sorry. The guy asked for Form_Open-- I was just
highlighting the fact that he asked for Form_Open and everyone is
jamming Form_Current down his throat.

It's like.. you guys listen even worse than I do sometimes.

Thanks

-Aaron
 
B

BruceM

The OP wrote:
"I would like the Time_In to populate automatically when the form opens"

As you may know, the form open event runs once when the form opens. It is
the first event to run. If you try to use the Open event to set a value in
the form's recordset by way of Me.Time_In = Now you will receive an error
message. I suppose you could open a recordset and update a record or group
of records, or maybe a variable could be created for later use, but there is
no reasonable way to assume this was what the OP intended.

The OP *did not* ask for the Open event. The OP used "open" in what was
surely a generic sense of the word.

message
Whatever Tony.

This silly kid is attacking me -- for no reason-- when I am the one
that is right in this thread.
--------------------------
Actually, it was "when the form opens", which really cannot be taken
as a
specific question about the form's Open event. In any case, the Open
event
is too soon to be writing to a record.
BTW, emoticons have their place, but a representation of a wink does
not
mitigate ugly jabs at people.
--------------------------

Do you think that 'when the form opens' can be interpreted as the
forms Open event?

I call hogwash; sorry. The guy asked for Form_Open-- I was just
highlighting the fact that he asked for Form_Open and everyone is
jamming Form_Current down his throat.

It's like.. you guys listen even worse than I do sometimes.

Thanks

-Aaron
 
A

a a r o n . k e m p f

the OP asked for 'form open'
Screw you, Bruce.

why don't you take your futile attacks elsewhere/

-Aaron
 
A

a a r o n . k e m p f

I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
 
A

a a r o n . k e m p f

I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
 
A

a a r o n . k e m p f

Tony;

You're the idiot that started real-world personal attacks.

So I'll gladly say and do whatever I want in this newsgroup.

I'm so sorry that you don't have the common sense to differentiate
between a newsgroup and real life.

-Aaron
 
B

BruceM

I had said I would not attempt to engage you in dialog, but then I foolishly
went back on that. However, what I am seeing in your posts suggests more
strongly than ever somebody who is losing his grip if not already in
freefall. I earnestly wish you the best in dealing with your demons. Good
bye.

message
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
I would like the Time_In to populate automatically when the form
opens.
 

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

Top