Copy and Paste from field to field

nomhs

New member
Local time
Tomorrow, 07:06
Joined
Sep 29, 2013
Messages
2
I'm wanting to be able to take the Address, City, State and Postcode field and copy them into another Address, City, State and Postcode field for postal/residential purposes. I've tried other forums and have had this suggested to be paste into the onClick Event but it doesn't work.
Private Sub SameAddress_Click()
Address = S_Address
City = S_City
State = S_State
Postcode = S_Postcode
End Sub

Any help would be appreciated.
 
Substitute your field names for txtcurrent and txtnew into this template.
Code:
Private Sub copyrecordbutton_Click()
On Error GoTo Err_copyrecordbutton_Click
Dim txtOld1 As Variant
Dim txtOld2 As Variant
Dim txtOld3 As Variant
Dim txtOld4 As Variant

txtOld1 = txtcurrent1.Value
txtOld2 = txtcurrent2.Value
txtOld3 = txtcurrent3.Value
txtOld4 = txtcurrent4.Value

RunCommand acCmdRecordsGoToNew

txtnew1.Value = txtOld1
txtnew2.Value = txtOld2
txtnew3.Value = txtOld3
txtnew4.Value = txtOld4

   
Exit_copyrecordbutton_Click:
    Exit Sub

Err_copyrecordbutton_Click:
    MsgBox Err.Description
    Resume Exit_copyrecordbutton_Click
    
End Sub
 
Worked a treat. As I'm using a checkbox is there a way to toggle this?
So when the checkbox is ticked the address copies and when it is not ticked the address in the field is removed.
Hope I have explained that right. Thanks again
 

Users who are viewing this thread

Back
Top Bottom