Results 1 to 4 of 4

Thread: Date on click

  1. #1
    Join Date
    Aug 2009
    Posts
    10

    Unanswered: Date on click

    --------------------------------------------------------------------------------
    I'm working with Access 2010 and don't know much code. I have a form with numerous data fields, and I would like the operator to just click in the field and it will populate with the current date and time. I've been told to enter the following code in the "on click" of the field's property sheet - Me.SignOff = Date() When I do that and then click in the field, I get the error message - "Microsoft Access cannot find the object 'Me.' If 'Me.' is a new macro or macro group, make sure you have saved it and that you have typed its name correctly." Any ideas on how to solve this??

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You must create an event handler for the OnClick property of the control (this usually appear in the Properties wondows as [Event Procedure]). This event handler is a sub whith a special name (related to the name of the concerned control) in the class module of the form. So if the control is named SignOff, you should have this code in the form module:
    Code:
    Private Sub SignOff_Click()
    
        Me.SignOff.Value = Date
    
    End Sub
    Have a nice day!

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    if you want the date AND the time probably better to use now() in place of date
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Talking

    Quote Originally Posted by kstarlin View Post
    --------------------------------------------------------------------------------
    I'm working with Access 2010 and don't know much code. I have a form with numerous data fields, and I would like the operator to just click in the field and it will populate with the current date and time. I've been told to enter the following code in the "on click" of the field's property sheet - Me.SignOff = Date() When I do that and then click in the field, I get the error message - "Microsoft Access cannot find the object 'Me.' If 'Me.' is a new macro or macro group, make sure you have saved it and that you have typed its name correctly." Any ideas on how to solve this??

    Here is a simple thing I did in A2K and pulled over into A2K3 and still works. I created a CheckBox and put this code in the AfterUpdate Event:
    Private Sub ckTimeOut_AfterUpdate()

    Code:
        If ckTimeOut = -1 Then
            TimeOut = Time()
            OutDate = VBA.Date
        ElseIf ckTimeOut = 0 Then
            TimeOut = ""
            OutDate = ""
        End If
    End Sub
    I have a field on the form called TimeOut. This was created to track salesmen coming in and out. Click the TimeOut checkbox and it puts the Time they checked out in the TimeOut field. Also did the same for TimeIn. Works beautifully and simple to do. Also, once you check it, IF you uncheck the box it just removes that time. Hope this helps some. As I said it works well for me.

    Have a nice day,
    Bud

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •