Results 1 to 5 of 5
  1. #1
    didiomm is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Dec 2013
    Posts
    47

    Timestamp on Buttonclick

    Hi All:

    I currently have a table that feeds a form with a column called "ConfirmationDate". Each time a record is updated in the form, I would like a button called "confirm" to be clicked. I would like a textbox on the form to populate with the date and time of the buttonclick. Each corresponding record in the table would also be updated with its respective buttonclick timestamp in the "ConfirmationDate" column. I tried doing this

    HTML Code:
    Private Sub cmdConfirmationDate_Click()
    Me.cmdConfirmationDate = Now()
    End Sub
    but the buttonclick updates all the ConfirmationDate records in the table instead of the record in view.

    I'd appreciate any ideas/help.



    Thanks!

    Didiomm

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Does it have to be a button click??

    I would try the "Form_BeforeUpdate" event.

    Lets say you have a table with a field named "ConfirmationDate".
    The table is bound to a form. On the form has text boxes bound field. One of the text boxes is bound to the field "ConfirmationDate". This text box is named "dTConfirmDate".
    The form is in Continuous Forms view.
    Each record is one line in the form.

    In the "Form_BeforeUpdate" event, you would have code like
    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
            Me.dTConfirmDate = Now()
    End Sub
    When you add a record or edit a record, the Before Update event will fire and will add the current date/time to the text box, then the data is saved.

    (I works for me in my dB.......)


    ----------------------------------------------
    BTW, in your code you are trying to set the button to Now(), not the control/field.
    Code:
    Private Sub cmdConfirmationDate_Click()  '<-- the name of the button 
        Me.cmdConfirmationDate = Now()
    End Sub

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by didiomm View Post

    ...but the buttonclick updates all the ConfirmationDate records in the table instead of the record in view...
    Are you sure that it is updating all of the Records in the Table...or are you simply seeing the same DateTime in the Control for all Records in the Form? If the latter, then your Control is Unbound...and this is normal behavior for an Unbound Control. The Control needs to be Bound to a Field in your underlying Table to be Record-specific.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    didiomm is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Dec 2013
    Posts
    47
    Ssnafu: good catch, thanks. And, it doesn't have to be a buttonclick. I maintained the single form view and used your suggested code and it seems to work. Thanks.

    Linq: you are right. During testing, I was making changes so quickly, it didn't seem the timestamp was registering for each record. But it seems they are - I double checked the seconds portion of the date/time stamp in the actual table to confirmed this.

    Thank you both, you've been helpful!

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Open PDF on Buttonclick
    By didiomm in forum Programming
    Replies: 7
    Last Post: 04-25-2016, 07:39 AM
  2. employee Timestamp in/out
    By pommie78 in forum Forms
    Replies: 5
    Last Post: 01-04-2015, 10:46 PM
  3. TimeStamp Issues
    By mike760534211 in forum Access
    Replies: 3
    Last Post: 01-08-2014, 04:51 PM
  4. Passthrough over a timestamp?
    By KrisDdb in forum Access
    Replies: 1
    Last Post: 01-10-2012, 06:42 PM
  5. Access Timestamp...
    By HMel in forum Access
    Replies: 4
    Last Post: 08-19-2008, 01:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums