471,874 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,874 software developers and data experts.

Copy field contents to another field based if a totally different field = true

I have no coding experience. I want to copy the contents from one field in table1 to a field in table2 if a totally different field in table2 is true.

I have created a form based on a query containing both of the two tables mentioned above. I am trying to attach the code to "After Update" for the totally different field mentioned above in table2.

Here is what I have tried and is obviously not working.

= Update [tblVenues].[VenueContactMailingAddress]
SET [tblVenues].[VenueContactMailingAddress] =
WHERE ([tblVenues].[VenueContactMailingAddressSame] = 0)
Jun 29 '16 #1
2 746
1,263 Expert 1GB
You can accomplish this without resorting to running an update query. The data is right there on the Form.

Try this:
Expand|Select|Wrap|Line Numbers
  1. if me.VenueContactMailingAddressSame<>False then
  2. me.VenueContactMailingAddress= me.VenueContactPhysicalAddress
  3. end if
This assumes all of those objects are on the screen, named in that way.

Jul 1 '16 #2
Hi jimatqsi,
I had problems using what you sent. Also, I have made some modifications. I hope you can help me with this.
I have 2 tables (tblContacts and tblVenues).

I have created physical addresses and mailing addresses in the tblContact table. I have created a relationship between the 2 tables on the common field "ContactID."

I have created a query made up of fields from both the tblContacts and tblVenues tables. I have created a form based on that query.

Here is what I would like to do.

If the tblContact table's field "ContactMailingAddressSame" (a check box for true/false) is not null, I would like to copy the data from and to the following fields (both in the tblContacts table).

ContactPhysicalAddress ====> ContactMailingAddress
ContactPhysicalCity ====> ContactMailingCity
ContactPhysicalState ====> ContactMailingState
ContactPhysicalZip ====> ContactMailingZip
ContactPhysicalCountry ====> ContactMailingCountry

Also, how would I use the code? Would I use the Expression Builder, the Code Builder, or the Macro Builder?

Any help would be greatly appreciated.
Jul 1 '16 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Jason Joines | last post: by
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.