Copy data from one field to another

theconfusedbear

Registered User.
Local time
Today, 00:45
Joined
Oct 12, 2006
Messages
18
I have one table with the following

address1
address1b
address1c
town
county
postcode

AND

feepayeraddress
feepayeraddress2
feepayeraddress3
town
county
postcode.

The question is users are filling in the address fields but want to hit a button on the form so that it copies the contacts address fields to the feepayers address fields .... I have tried different queries etc but i cant do it ... its annoying me! HELP PLEASE
 
If all the fields are on the form why not use an After Update Event behind the last field that gets updated (Post Code)

It would be something like.

me.feepayeraddress.value = me.address1
me.feepayeraddress2=me.address1b
me.feepayeraddress3=me.address1c

If they aren't on the same form you could look at using an Update Query as long as there is some common fields.
 
You don't need the same data in two tables.
 
I have done an update query and an append query ... which only creates a new record with only the feepayers details in it ... im really stuck
 
MStef is right you don't need the data in 2 tables, but what are you trying to achieve?

Would it be useful to upload a sample of your database so someone can take a look for you, make sure you specify the table names and form name, add some more detail in this thread.
 
One table with two address sets in the table - one for the client address fields and one for the feepayers address fields. 90% of the client addresses need to be copied to the feepayers address details. So all I want to do is have a button the form which appends the data from the clients address fields to the feepayers address fields.
 
One table with two address sets in the table - one for the client address fields and one for the feepayers address fields. 90% of the client addresses need to be copied to the feepayers address details. So all I want to do is have a button the form which appends the data from the clients address fields to the feepayers address fields.


Then follow my advice and just place the code into your command button.

me.feepayeraddress.value = me.address1
me.feepayeraddress2=me.address1b
me.feepayeraddress3=me.address1c
 
Ok I have done that .... but it just wipes the address from the address and doesnt put anything into the feepayer address
 
Tried and tested

Private Sub cmdCopyAddress_Click()
Me.feepayeraddress1.Value = Me.address1.Value
Me.feepayeraddress2.Value = Me.address1b.Value
Me.feepayeraddress3.Value = Me.address1c.Value
End Sub
 
trevor I really appreciate your efforts but its still removing the line. I have just done the first address line - I hit the button and the data disappears from the field. And doesnt reappear in the feepayers first address line .. Im sure that im annoying you enough but I would really appreicate it if you could help
 
Are you saving the record before you click the button. What do you have behind the button?

If you aren't saving then perhaps add a save command first

DoCmd.RunCommand acCmdSaveRecord

Then the other code
 
I would like to concur and elaborate on the comment by MStef and backed by TrevorG.

A properly normalized database would separate the addresses into a related table. The ContactAddress and PayerAddress would be Long Integer fields containing a foreign key to the PK in the Addresses table.

Copying the ContactAddress to the PayerAddress would simply involve the copying of the key.

If I was designing this database I would have a Persons table. The Contact and Payer would be entered as a key to the Persons table. The Addresses would be related to Persons. This structure allows any number of addresses for any Person.
 

Users who are viewing this thread

Back
Top Bottom