Copy Data from One Field to Another

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
 
N

Naresh Nichani MVP

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
 
D

Deb Roberts

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
 

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

Top