Hidden Date and time stamp?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • slenish
    Contributor
    • Feb 2010
    • 283

    Hidden Date and time stamp?

    I am wondering how do I create a hidden date stamp and I could also add a time stamp if I wanted to. So what would happen is once information is entered in to a form and then saved I want to make it so on the table it auto populates a column with todays date.

    I feel like an idiot asking what im sure is very simple problems.

    I really apperciate all the help from everyone out there has been giving me.
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    an information cahnge on any field of the form or on a particular field on the form.

    Either way you need to add VB code to an appropriate event
    AfterUpdate on the form or control for example.

    The code changes the hidden controls value like so
    Code:
    txtHiddenDate=Now()

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32661

      #3
      Now() gives both date & time. Date() & Time() functions are also available if required.

      Comment

      • slenish
        Contributor
        • Feb 2010
        • 283

        #4
        Ok i got it to work sort of. Now im getting and error saying " I can not go to the specified record"

        Any idea why its doing that? I just want to save the record and go on to the next one. Do i need to add in a DoCmd,update Record command??

        Comment

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

          #5
          I would put the code by Delerna in the BeforeUpdate of the Form.

          If you want us to help with debugging your code....you need to provide the code.

          Comment

          • missinglinq
            Recognized Expert Specialist
            • Nov 2006
            • 3533

            #6
            I agree with Smiley. The Form_AfterUpdat e is too late to add data to the record, Form_BeforeUpda te is the place to assign this value.

            And no, Access will automatically save the record when you move to another record or close the form.

            Linq ;0)>

            Comment

            • slenish
              Contributor
              • Feb 2010
              • 283

              #7
              Ok I finally got this to work with way a lot of playing around and actually found out there are 2 ways to do this.

              First off the code provided by Delerna is only part of it. What I had to do was first set the beforeUpDate data to txtHiddenData = Now() Then I had to create a hidden box and set the beforeUpDate on that box to =Int (Now()) and presto it finally worked with out any errors giving me both the time and date in the table.

              Also I figured out another way to get this to work as well but only gave me the date. What you can do is create a hidden box set it to a table then set the Defult Value under the Data tab to =Int (Now()) and that will also give you the date each time you save.

              Thank you so much to everyone really apperciate all the help. Im sure i will be back with some new questions before to long.

              Thanks again :)

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32661

                #8
                Slenish, you're not explaining yourself very clearly. I'm still unclear on whether you are looking for a date stamp, a date & time stamp or two separate stamps for date & time.

                Whatever it is you do want, using Int(Now()) in place of the more logical Date() is not a good idea (See post #3). It doesn't make your code easy to read or maintain.

                I tried to understand what you were on about when you were talking about creating a new hidden 'box' on your form, but I couldn't make any sense of it, and I couldn't imagine why you felt it was necessary.

                Comment

                Working...