Copy mulitple fields

R

rico

Hello,

I am trying to create some code to put on a button, that will copy certain
fields in a form and paste them to the same fields in a new record. I'm not
getting very far!! Call fields field1 field2 etc, am using Access 2003. All
help much appreciated.

TIA

Rico
 
D

Dirk Goldgar

rico said:
Hello,

I am trying to create some code to put on a button, that will copy
certain fields in a form and paste them to the same fields in a new
record. I'm not getting very far!! Call fields field1 field2 etc, am
using Access 2003. All help much appreciated.

TIA

Rico

Here's an example. Note that it's "air code":

'---- start of example code -----
Private Sub cmdCopyToNewRecord_Click()

Dim varField1 As Variant
Dim varField2 As Variant
Dim varField3 As Variant

varField1 = Me!Field1.Value
varField2 = Me!Field2.Value
varField3 = Me!Field3.Value

' Force save of current record, if it has been modified.
If Me.Dirty Then Me.Dirty = False

RunCommand acCmdRecordsGoToNew

Me!Field1 = varField1
Me!Field2 = varField2
Me!Field3 = varField3

End Sub
'---- end of example code -----
 
Top