469,072 Members | 1,860 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,072 developers. It's quick & easy.

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

3
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] =
[tblContacts].[VenueContactPhysicalAddress]
WHERE ([tblVenues].[VenueContactMailingAddressSame] = 0)
Jun 29 '16 #1
2 685
jimatqsi
1,256 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
  4.  
This assumes all of those objects are on the screen, named in that way.

Jim
Jul 1 '16 #2
hunths
3
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 zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.