Help with Time Stamp fields

D

Doug_C

Hello,

I am looking to set up two fields on my form under Time Spent. The two
fields are "Start" and "Finish". I want to put a command button on the bottom
of each of these so when the user clicks it, it populates the current time.
However, I do not want the user to be able to manual change the time in the
field.

Question one: Once I set up the fileds and command buttons, what will be the
code to make the current time populate in the field and where do I place the
code?

Question Two: How do I make the two fields so the user cannot at any time
manual change the time that populates?

I realize that can change it by continuing to click the button but I don't
want them to be able to free form the time.

Any help would be greatly appreciated!! Also, please simplify as I am at a
novice level.

Thanks much!!!
 
R

Rick Brandt

Doug_C said:
Hello,

I am looking to set up two fields on my form under Time Spent. The two
fields are "Start" and "Finish". I want to put a command button on
the bottom of each of these so when the user clicks it, it populates
the current time. However, I do not want the user to be able to
manual change the time in the field.

Question one: Once I set up the fileds and command buttons, what will
be the code to make the current time populate in the field and where
do I place the code?

Me!TextBoxName = Now()

would be the code in the Click event of both buttons. The only difference
would be the name of the TextBox used in each statement.
Question Two: How do I make the two fields so the user cannot at any
time manual change the time that populates?

Set the Locked Property of the TextBoxes to Yes.
 
J

Joy

I think that I am trying to do what is in Question one but I don't really
understand it. Can you please break it down and explain it to me? I'm just
and Access beginner.
 
J

John W. Vinson

It sounds like you may want to simply set the DefaultValue property of the
field to =Now(). This will cause the current date and time to fill in the
instant a new record is started.
 
J

Joy

What I'm attempting to do (which may not work) is to have one field and 2
buttons on a form. The field is to enter someones name and one button is
"time in" and the other "time out". I'm trying to get the time in/time out
to go into a table that I have set up. I'm afraid I am making this to
difficult for my brain.
 
J

John W. Vinson

What I'm attempting to do (which may not work) is to have one field and 2
buttons on a form. The field is to enter someones name and one button is
"time in" and the other "time out". I'm trying to get the time in/time out
to go into a table that I have set up. I'm afraid I am making this to
difficult for my brain.

For entering the name I'd certainly use a Combo Box control (so the user can
select their name from a list rather than having to type it all out).

The command button should be very simple. Let's say you have a textbox on the
form named txtTimeIn bound to the time in field, and a command button named
cmdTimeIn. View the Properties of the form; select cmdTimeIn; find the "Click"
event on the Events tab, and click the ... icon by it. Choose "Code Builder".
Access will give you the Sub and End Sub lines - just edit in one more:

Private Sub cmdTimeIn_Click()
Me!txtTimeIn = Now
End Sub

Do the same for time out.
 
J

Joy

Thanks for your help but I can't seem to get it to work. I have everything
set up but when I click the command button nothing happens. Am I suppose to
replace the Me in the

Private Sub cmdTimeIn_Click()
Me!txtTimeIn = Now
End Sub

I have tried everything I can think of.
Joy
 
J

John W. Vinson

Thanks for your help but I can't seem to get it to work. I have everything
set up but when I click the command button nothing happens. Am I suppose to
replace the Me in the

Private Sub cmdTimeIn_Click()
Me!txtTimeIn = Now
End Sub

I have tried everything I can think of.

Me! should be correct; it just means "this current form".

Is there in fact a Textbox control on the same form as the command button,
named txtTimeIn? Is it bound to the time in field in the Form's Recordsource
query?
 
Top