How do you make a date / time stamp while starting a new entry?

G

Guest

My database is used to log and journal technical calls for our product. It
is important for me to keep a date and time for everytime I receive and end a
call. Same thing with any journals that I have attached to that call record.
How do I Make a Date / Time stamp appear when I start a new record (when
clicking the 'New Record' button) and when I end the record (when clicking
the 'Save Record' button)? The date / time can not change once it's been
"stamped".
Thank you.
 
D

Douglas J. Steele

In the table, set the default for the field to Now()

In the form's BeforeInsert (or BeforeUpdate if you want it to change each
time the record's reviewed), put code to set the field to Now().
 
G

Guest

Open the table in design view, in the field properties set the Default value
of the field to:

Now()
will return the current date and time

Date()
will return the current date

Time()
will return the current time
 
R

Rick B

Just add a field to your table for the start and end date/time. Add these
to your form. Personally, I would not make them visible.

Set the default value on the start time to =Now()
Or, you could use the "before insert" event and set the field "when the
first character is typed in a new record". This would be best if you leave
the form sitting open and at a blank record between calls.


Use code to set the end time to Now() put the code in the "before
update" event.

I have not tested those events, so make sure it does what you expect.
 
G

Guest

If I'm not mistaken, that will change the date / time everytime I open, or
view the form, correct? It's important that the date / time is stamped in so
that it won't change everytime I go into that form for review.

Also, this is only for the start of the form, this won't help me when I save
the form. How could I enter this 'stamp' when I save the form? Remember, I
must keep it so that it won't change when I go back and review it.
 
R

Rick Brandt

Shawn said:
If I'm not mistaken, that will change the date / time everytime I
open, or view the form, correct?

No. It will be set when a new record is created and then won't change again
(unless you change it).
 
G

Guest

We're half way there. I have the Beginning date/time working. I tried
puting the "Now() in the "before update" event but it didn't work. I did
this through the form and in the property for the Ending Date, hoping that
the date/time would show up after saving or exiting the newly created event.
Was I supposed to do this somewhere within the Table? I couldn't find the
"before update" option within the table. Am I doing something wrong?
 
R

Rick B

You have to write code that runs on the before update event.

Select "event procedure". Then click the triple dots to go into the vba
script.

Make your code something like...

Private Sub Form_BeforeUpdate(Cancel As Integer)
SomeControlName = Now()
End Sub




replace "SomeControlName" with the name of your control.
 
G

Guest

What I did (which hasn't worked):
1) Opened the form in Design Mode.
2) Went into the properties of my Textbox (End Time).
3) Wnt into the Before Update box and click the "..."; which is beside the
[Event Procedure].
4) I simply copied your suggestion and pasted it in the code.
5) I suggested putting the "Me." suggested, but it didn't help. I
presented a drop-down of options, but I didn't do anything w/ it.

I'm sure that I have to create a Control & a name for the control. How?
 

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