Multiple fields update one field

  • Thread starter Thread starter meghanwh
  • Start date Start date
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.
 
Private Sub Form_Dirty(Cancel As Integer)
Me.HomeAddrUpdate = Date
End Sub

--
Ruel Cespedes
Sr. Programmer Analyst
(e-mail address removed)

Message posted via AccessMonster.com
 
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()
 
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?
 
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()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top