Date Update!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TrisH

    Date Update!

    I can't out figure what I've missed out or done wrong!! I have a
    database which has a 'Last Update' field. This field has a general of
    Short date & Default Value: Date(), which works well when a new record
    is input, but when that record is updated by a user, say the next day,
    the date isn't changing to the new date. I have tried with the
    Default value as Now() and even created a new field for this to see if
    there is any change, but nothing is changes.

    Can anybody please throw some light on as to how I can get the date to
    change to the date data is changed??

    Thank you in advance

    Trish
  • Allen Browne

    #2
    Re: Date Update!

    Access cannot do this at the table level.

    However, if your updates are made through a form, you can use the
    BeforeUpdate event procedure of the form:

    Private Sub Form_BeforeUpda te(Cancel As Integer)
    Me![Last Update] = Now()
    End Sub

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "TrisH" <Trishart2000@y ahoo.co.uk> wrote in message
    news:deccaeb.04 02080250.726124 0@posting.googl e.com...[color=blue]
    > I can't out figure what I've missed out or done wrong!! I have a
    > database which has a 'Last Update' field. This field has a general of
    > Short date & Default Value: Date(), which works well when a new record
    > is input, but when that record is updated by a user, say the next day,
    > the date isn't changing to the new date. I have tried with the
    > Default value as Now() and even created a new field for this to see if
    > there is any change, but nothing is changes.
    >
    > Can anybody please throw some light on as to how I can get the date to
    > change to the date data is changed??
    >
    > Thank you in advance
    >
    > Trish[/color]


    Comment

    • Bas Cost Budde

      #3
      Re: Date Update!

      TrisH wrote:
      [color=blue]
      > I can't out figure what I've missed out or done wrong!! I have a
      > database which has a 'Last Update' field. This field has a general of
      > Short date & Default Value: Date(), which works well when a new record
      > is input, but when that record is updated by a user, say the next day,
      > the date isn't changing to the new date. I have tried with the
      > Default value as Now() and even created a new field for this to see if
      > there is any change, but nothing is changes.[/color]

      DefaultValue applies only when the record is newly created. And since
      Access (or Jet, the database engine) does not provide triggers, that is
      some procedures that run on certain table events, you cannot fully have
      this.

      However, if all your table manipulation by users is through forms, you
      can use the AfterUpdate event of the form to set the date field.

      --
      Bas Cost Budde

      but the domain is nl

      Comment

      • Bas Cost Budde

        #4
        Re: Date Update!

        Allen Browne wrote:
        [color=blue]
        > Private Sub Form_BeforeUpda te(Cancel As Integer)
        > Me![Last Update] = Now()
        > End Sub[/color]

        Aw, I said AfterUpdate, but that is bound to fail...

        Addition: you can shake the square brackets if you don't use spaces in
        object(field, table, form, query, report...) names.

        --
        Bas Cost Budde

        but the domain is nl

        Comment

        • Lyle Fairfield

          #5
          Re: Date Update!

          Bas Cost Budde <bas@heuveltop. org> wrote in news:c055r9$umj $5
          @news2.solcon.n l:[color=blue]
          > Addition: you can shake the square brackets[/color]

          Is this some Salvation Army ritual?

          --
          Lyle
          (for e-mail refer to http://ffdba.com/contacts.htm)

          Comment

          • Bas Cost Budde

            #6
            Re: Date Update!

            Lyle Fairfield wrote:
            [color=blue][color=green]
            >>Addition: you can shake the square brackets[/color]
            >
            > Is this some Salvation Army ritual?[/color]

            No, but it can be seen with Morris dancers.

            --
            Bas Cost Budde

            but the domain is nl

            Comment

            • TrisH

              #7
              Re: Date Update!

              Bas Cost Budde <bas@heuveltop. org> wrote in message news:<c055r9$um j$5@news2.solco n.nl>...[color=blue]
              > Allen Browne wrote:
              >[color=green]
              > > Private Sub Form_BeforeUpda te(Cancel As Integer)
              > > Me![Last Update] = Now()
              > > End Sub[/color]
              >
              > Aw, I said AfterUpdate, but that is bound to fail...
              >
              > Addition: you can shake the square brackets if you don't use spaces in
              > object(field, table, form, query, report...) names.[/color]

              I've tried the above, but it still isn't updating with both the before
              update & after update. I have made a form for the table concerned,
              but it's still not playing. Is the bit in brackets case sensitive?

              Comment

              • Bas Cost Budde

                #8
                Re: Date Update!

                TrisH wrote:
                [color=blue]
                > I've tried the above, but it still isn't updating with both the before
                > update & after update. I have made a form for the table concerned,
                > but it's still not playing. Is the bit in brackets case sensitive?[/color]

                No, it isn't.
                Please make sure the event really fires. You can set a breakpoint (press
                F9 with the cursor on the =Now line) or put an extra line with MsgBox
                "Hello" in the procedure; try editing; do you get at that spot?

                If no: is the AfterUpdate (no, BeforeUpdate) *property* of the form set
                to [Event Procedure]?
                --
                Bas Cost Budde

                but the domain is nl

                Comment

                Working...