Copy button in a Form to copy fields to other fields in the same record

Quinten

New member
Local time
Today, 21:16
Joined
Sep 23, 2005
Messages
6
Copy-Paste button in a Form to copy-paste fields to other fields in the same record

Hi there,

Can someone help me on this issue?

I want to copy Postal Address Information to Visit Address Information wthin the same record, in my Contact Database that I am building at the moment.

I want to copy 4 fields to 4 other fields within the same Record.

This the current code I use for the Copy-button:

---

Private Sub cmdCopyFields_Click()

Dim v1 As Variant
Dim v2 As Variant
Dim v3 As Variant
Dim v4 As Variant


v1 = Me!Field_a.Value
v2 = Me!Field_b.Value
v3 = Me!Field_c.Value
v4 = Me!Field_d.Value


RunCommand acCmdRecordsGoToNew

Me!Field_e = v1
Me!Field_f = v2
Me!Field_g = v3
Me!Field_h = v4


End Sub


---

The underlined part (acCmdRecordsGoToNew) is false part of this code, because it copies the Adress Info to a new record, instead of copying it in the same.

-Is there someone that can help me with this problem, to make the copy-button in the Form run properly?

-Are there other options to achieve te same?

I have put in a attachment, to give you guys a visual example of what I mean.



Thanks in advance,

Quinten
 

Attachments

  • Testform.jpg
    Testform.jpg
    51.2 KB · Views: 188
Last edited:
Quinten,

There are many ways to do this. But create and run an Update query is the simplest way to perform this.

I attached a copy of sample db. I set CompnayId field not as Autonumber but it will not accept duplicate. But you can set according your requirement.Hope this will help you.

Ashfaque
 

Attachments

Hi,

Thanks for the reply.
This should do the trick.
I was thinking way to difficult ...

Thanks,

Quinten
 

Users who are viewing this thread

Back
Top Bottom