Copy Data from One Field to Another

  • Thread starter Thread starter Deb Roberts
  • Start date Start date
D

Deb Roberts

I have a contacts table which contains a series of fields for Address
(Address1, Address2, Suburb, State, Postcode, Country), then another set of
fields for Mailing Address (MailAddress1, MailAddress2, MailSuburb) etc etc.

These fields are all visible on a Contacts Overview form.

On close of the form, I would like to have a macro/code that checks whether
the Mailing Address fields are empty, and if so, then copy the Street
Address fields into the appropriate areas.

I've been able to create a macrobutton using the SetValue action which does
this while the form is open, but unfortunately it only does it on the active
record, not all records.

Ideally the macro should run when the form is closed, and it should affect
all records.

Can anyone please help with this.

Thanks

Deb Roberts
 
Hi:

You could design a UPDATE query and run it from your macro.

Query SQL could be something like this --

UPDATE [YourTable] Set [MailingAddress2]=[MailingAddress1] Where
([MailingAddress1] Is Null or [MailingAddress1]="")

This updates all records MailingAddress1 is Null or Blank.

You would seperate SQL statements for each field to update as the Where
condition is different for each SQL.

Regards,

Naresh Nichani
Microsoft Access MVP
 
Thanks I'll give this a go.

Deb
=====

Naresh Nichani MVP said:
Hi:

You could design a UPDATE query and run it from your macro.

Query SQL could be something like this --

UPDATE [YourTable] Set [MailingAddress2]=[MailingAddress1] Where
([MailingAddress1] Is Null or [MailingAddress1]="")

This updates all records MailingAddress1 is Null or Blank.

You would seperate SQL statements for each field to update as the Where
condition is different for each SQL.

Regards,

Naresh Nichani
Microsoft Access MVP


Deb Roberts said:
I have a contacts table which contains a series of fields for Address
(Address1, Address2, Suburb, State, Postcode, Country), then another set of
fields for Mailing Address (MailAddress1, MailAddress2, MailSuburb) etc etc.

These fields are all visible on a Contacts Overview form.

On close of the form, I would like to have a macro/code that checks whether
the Mailing Address fields are empty, and if so, then copy the Street
Address fields into the appropriate areas.

I've been able to create a macrobutton using the SetValue action which does
this while the form is open, but unfortunately it only does it on the active
record, not all records.

Ideally the macro should run when the form is closed, and it should affect
all records.

Can anyone please help with this.

Thanks

Deb Roberts
 
Back
Top