Multiple fields update one field

M

meghanwh

I have an address block on a form, with separate fields for street,
city, state, etc. for both home address and business address. I have a
separate field in which I'd like to update when the addresses are
updated. So for the "HomeAddrUpdate" field, anytime anything in any of
the home address fields is changed I'd like to put the date. Is there a
way to code this in Access? I know how to use the OnDirty function for
a form or a single field, but is there a sub I can write to encompass
multiple fields? Thanks.
 
R

Ruel Cespedes via AccessMonster.com

Private Sub Form_Dirty(Cancel As Integer)
Me.HomeAddrUpdate = Date
End Sub
 
M

Marshall Barton

I have an address block on a form, with separate fields for street,
city, state, etc. for both home address and business address. I have a
separate field in which I'd like to update when the addresses are
updated. So for the "HomeAddrUpdate" field, anytime anything in any of
the home address fields is changed I'd like to put the date. Is there a
way to code this in Access? I know how to use the OnDirty function for
a form or a single field, but is there a sub I can write to encompass
multiple fields?


Create a Sub procedure in the form's module:

Sub SetDate()
Me.HomeAddrUpdate = Now ' or Date
End Sub

Then select (shift click) all the address controls and set
their AfterUpdate event **property** to:
=SetDate()
 
M

meghanwh

Marshall said:
Create a Sub procedure in the form's module:

Sub SetDate()
Me.HomeAddrUpdate = Now ' or Date
End Sub

Then select (shift click) all the address controls and set
their AfterUpdate event **property** to:
=SetDate()

Thanks. I've put that code in, and now I get an error: The expression
AfterUpdate you entered as the event property setting produced the
following error: The expression you entered contains invalid syntax.

Any ideas?
 
M

Marshall Barton

Thanks. I've put that code in, and now I get an error: The expression
AfterUpdate you entered as the event property setting produced the
following error: The expression you entered contains invalid syntax.


Sorry, that should have been:

Public Function SetDate()

instead of
Sub SetDate()
 
Top