How to refresh time on Form's textbox?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AccessBeetle
    New Member
    • Jul 2009
    • 111

    How to refresh time on Form's textbox?

    I have a form which has a textbox called TimeStamp. When we enter a record, it fills current as well as the next record's TimeStamp as the current time. This seems a bit weired. It should fill the time when a person actually starts to enter the record.

    Also, sometimes if it takes more than 5 minutes to enter the whole record, in that case the time is still the same as it was when I started to enter the record.
    Is there any way we can refresh the time?

    Something to be done in Textbox's afterUpdate event may be??

    Here is some properties of the textbox,

    Default Value:Format(No w(),"Medium Time")
    Input Mask: 00:00;
    Thanks
  • MrDeej
    New Member
    • Apr 2007
    • 157

    #2
    You should use one (or more) of the forms events and write VBA

    me.text0 = now

    Comment

    • AccessBeetle
      New Member
      • Jul 2009
      • 111

      #3
      I tried to put
      Me.txtTimeStamp =Format(Now()," Medium Time")
      in forms's AfterUpdate event. It didn't work.
      Any other solution??

      Comment

      • MrDeej
        New Member
        • Apr 2007
        • 157

        #4
        You are almost there.. read the description on the forms events to find an event that suit you. I havent used a bound form for some years so i have forgotten which is right.

        Or you could put the code on the other textboxes afterupdate event.

        Comment

        • AccessBeetle
          New Member
          • Jul 2009
          • 111

          #5
          OK I got it. I put it under the AfterUpdate event of the other textbox on the same form.
          Thanks
          Code:
          Private Sub Comments_AfterUpdate()
          Me.Text42.Value = Format(Now(), "Medium Time")
          End Sub

          Comment

          • TheSmileyCoder
            Recognized Expert Moderator Top Contributor
            • Dec 2009
            • 2322

            #6
            If you want the time recorded to be the time where the record is saved, you should put it in the before_Update event.

            Placing it in the After_Update will update the time AFTER you saved your record. This also means that your Dirtying the form again, and that if a user preses esc, or undo, the timestamp wont be saved.


            You should also store the full time.
            Code:
            Me.Text42.Value=Now()
            And then set the format of the textbox to only display the part you want.

            Comment

            • missinglinq
              Recognized Expert Specialist
              • Nov 2006
              • 3533

              #7
              If he was using the Form_AfterUpdat e event, you'd be right, Smiley, but he's using the AfterUpdate event of a control on the form, Comments, not the Form_AfterUpdat e event.

              To record the time the record is saved place the code in the Form_BeforeUpda te event.

              Linq ;0)>

              Comment

              • AccessBeetle
                New Member
                • Jul 2009
                • 111

                #8
                Thanks for the input guys. I wanted to save the "time" when the user is done with that record. Missinglinq, you are right. When I put the code under Comment_AfterUp date, it was changing the time as soon as the user is done with only "Comments" textbox. If you put it under Form_BeforeUpda te it will wait until you are "completely " done with that record.
                Thanks for the input all you guys!!

                Comment

                Working...