Connecting Tech Pros Worldwide Help | Site Map

Using a subroutine to populate a field in Access - how to tie to field?

Blake Patterson
Guest
 
Posts: n/a
#1: Nov 12 '05
I have a subroutine I want to run whenever an Access record is
updated.

Sub Form_BeforeUpdate(Cancel As Integer)
Me!LastUpdated = Now
End Sub

It updates this date field with the current date whenever a record is
changed. How do I tie this sub to the field in Access, so that it
fires on change?

Thanks.




bp
Allen Browne
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Using a subroutine to populate a field in Access - how to tie to field?


Access does not have triggers, so you cannot achieve this at the
table-level.

The code you have is the right approach, provided all changes are made
through the form.

--
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.

"Blake Patterson" <blake@blakespot.com> wrote in message
news:90552177.0401291405.63d5ed8f@posting.google.c om...[color=blue]
> I have a subroutine I want to run whenever an Access record is
> updated.
>
> Sub Form_BeforeUpdate(Cancel As Integer)
> Me!LastUpdated = Now
> End Sub
>
> It updates this date field with the current date whenever a record is
> changed. How do I tie this sub to the field in Access, so that it
> fires on change?[/color]


Pieter Linden
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Using a subroutine to populate a field in Access - how to tie to field?


blake@blakespot.com (Blake Patterson) wrote in message news:<90552177.0401291405.63d5ed8f@posting.google. com>...[color=blue]
> I have a subroutine I want to run whenever an Access record is
> updated.
>
> Sub Form_BeforeUpdate(Cancel As Integer)
> Me!LastUpdated = Now
> End Sub
>
> It updates this date field with the current date whenever a record is
> changed. How do I tie this sub to the field in Access, so that it
> fires on change?
>
> Thanks.[/color]

if you want the date the *Field's* value was last changed, then put it
in the AfterUpdate of the field's control.
Closed Thread