time update command button for record

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

Guest

I want a record to fill the time and date in when I click a button. When I
click the button, I want the current time and date to be filled into the
field. How can this be done?
 
I'm getting an error, it is saying that there is no specific macro linked to
this button. What do I do? I typed in "Me!In = Now ()" on the on-click
function. Is there something wrong with it. The name of the field is "In"
 
in message:
I'm getting an error, it is saying that there is no specific macro linked to
this button. What do I do? I typed in "Me!In = Now ()" on the on-click
function. Is there something wrong with it. The name of the field is "In"

You are just entering that command directly onto the Property line of that
particular event. What you need to do is remove what you have there and
then hit the button with three dots just to the right of it [...] Clicking there
will pop up the Choose Builder dialog box. Select "Code Builder" and then
hit OK. You will be taken to the code window for this form and specifically
the event procedure in question for that control. The beginning and ending
of the procedure will already be filled in with something like so:

Private Sub cmdMyButton_Click()

End Sub

Now just enter this one line of code in between there:

Private Sub cmdMyButton_Click()
Me![In] = Now ()
End Sub

Compile the code, save and close the form. That should do it.

BTW using "In" as a field name is not a good idea since it is an Access/Jet
Reserved Word. Better to use something like TimeIn.

See this link for a list of field/control names to avoid:

http://www.ltcomputerdesigns.com/JCReferences.html#ReservedWords

Hope that helps,
 
Back
Top