INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Form Basics

Add Current Date with a Button by Garridon
Posted: 19 Apr 02 (Edited 5 Nov 02)

You can add a button to your form that, when clicked will add the current date for your user to a field.

Create a button and call it cmdAddDate.  Insert the code below into the On Click event procedure of the button.  The field txtCompleted refers to the field you want to insert the date into.

Private Sub cmdAddDate_Click()
On Error GoTo ErrorAddDate

    Me.txtCompleted = Date

ExitAddDate:
    Exit Sub

ErrorAddDate:
    MsgBox Error.Description
    Resume ExitAddDate
End Sub

For date and time, use the following code.  Make sure you change the field's Format properties to General Date.

Private Sub cmdAddDate_Click()
On Error GoTo ErrorAddDate

    Me.txtCompleted = Now()

ExitAddDate:
    Exit Sub

ErrorAddDate:
    MsgBox Error.Description
    Resume ExitAddDate
End Sub

Back to Microsoft: Access Forms FAQ Index
Back to Microsoft: Access Forms Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close