General discussion

Locked

Udate Field

By apopowski ·
In Access 2000 and 2002 I want to include a Date field that shows when the record was changed. I want the field to put the Date in automaticly. Also so it can't be changed.

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Udate Field

by Karpi In reply to Udate Field

Hello,

I would use the OnDirty-Form-Event.

- Place the Datefield in the Forms-Page-Header-Section (it is invisible to the User)
- In the OnDirty-Event you may use the following code:

Me.MyDateField=Now


eventually try the Forms BeforeUpdate-Event

HTH
Karpi
<fluctuat nec mergitur>

Collapse -

Udate Field

by apopowski In reply to Udate Field

Poster rated this answer

Collapse -

Udate Field

by stephen.burns In reply to Udate Field

You cannot protect the field in the table if the user can open a table for update. Access security only restricts access at the table level and does not provide security to columns(fields). Therefor you must hide the database window and provide the user with a compiled version of the Access database - A ".MDE" file.

with the users restricted to accessing the data through forms it is very straightforward to do what you ask.

Assume you create a datetime field in the table called "DateUpdated".

On the form where the users maintain the table you create a textbox with the following properties:
Tab field value
(data) Control Source DateUpdated
(data) Default Value =now()
(format) Visible No

The "Visible" property will stop the field being displayed, thus stopping the users from altering it or even knowing it exists.

The "Default Value" property ensures that when a new record is created the field is automatically updated with the creation date and time. To ensure the date field is updated every time the record is altered you have to add an event procedure to the form.

On the properties dialog for the form, select the events tab, then create the following event procedure for the "Before Update" event:

Private Sub Form_BeforeUpdate(Cancel As Integer)
me.DateUpdate=Now()
End Sub

When the user adds or modifies a record, your field will be updated to contain the current date and time. The user cannot see the field and therefore can't change it. If you wish the user to see the field but still be unable to change it then on the fields properties let the
(format tab)Visible property remain as "yes" and change the (data tab)Enabled property to "No". This will display the field "Greyed Out" and the user will not be able to alter its contents. The On Update event will still be able to update the field.

Collapse -

Udate Field

by apopowski In reply to Udate Field

Poster rated this answer

Collapse -

Udate Field

by apopowski In reply to Udate Field

This question was closed by the author

Back to Software Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums