• Update (Access 2000)

    Author
    Topic
    #374043

    I am trying to make a field that as soon as you edit existing rows in a table the field will give the present date. This will be a property on a form that shows when the document was last updated. Thanks.

    Viewing 0 reply threads
    Author
    Replies
    • #603621

      Let’s assume this field is named DateLastUpdated, and you place a textbox (name it txtDateLastUpdated) on your form that is bound to the field. In your form’s BeforeUpdate event, place this line of code:
      txtDateLastUpdated = Date( )

      • #603630

        I am sorry, but this did not work. I want the form to show the date updated, but this is a read only form. The updates are going to be in the tables. If you can help me, I would really appreciate it.

        • #603667

          You can’t find out when a record was updated without using a field in your table to record that date, and without using appropriate code in the forms used to update the records. If you are updating records by accesssing the table directly, then you’re out of luck; tables don’t have events that you can put code in. If you want to remember when a record was created then you can just put date() as the default for the field in the table (although the value can always be changed if you give people read-write access to the table directly).

          Not sure what you mean by the comment that you are using a read only form. If you can’t change the data then clearly there’s no update to record. You’ll need to put the code previously mentioned in the forms that are used to update the records. As long as you stick it in the beforeupdate event code, simply viewing the record won’t cause the value to be changed.

        • #603717

          There is no way for you to control when a record in a table get updated, unless you do it thru a form. Do you mean that data entry is being done directly into the table? This isn’t a good idea.

      • #603739

        I tried to use the coding, but I still can not get it to work. I am the only person changing information, so it does not matter if I updte in the table or form. Please write back if you can help me. Thanks

        • #603786

          The coding will work only if you do data entry via the form, but you said your form is read-only. There is NO WAY in table entry to detect that a record has been changed, nor to automatically do anything. The ONLY way to get this functionality is to do data entry via a form.

          • #603899

            The form is no longer a read only. I tried changing data in the form, and I am not getting a new date.

            • #603906

              You wrote:
              >>The form is no longer a read only. I tried changing data in the form, and I am not getting a new date. <<

              What code are you using and where is the code located?

            • #603913

              I am using the code txtDateLastUpdated, and it is under BeforeUpdate in the coding. txtLastUpdated is the Name of the label for Last updated(the field.)

            • #603972

              You wrote:
              >>I am using the code txtDateLastUpdated, and it is under BeforeUpdate in the coding. txtLastUpdated is the Name of the label for Last updated(the field.) <<

              First, let's get some terminology straight. I assume you mean that txtLastUpdated is the name of the textbox control that is bound to the field LastUpdated? A Label is another control type, and is not bound to a field.

              Then you said you were "…using the code txtDateLastUpdated". Exactly what do you mean by that? Could you show me the exact code you are using? And is this code in the Form's BeforeUpdate event? (each control has a BeforeUpdate event also.)

    Viewing 0 reply threads
    Reply To: Update (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: