Copy & Paste previous record

  • Thread starter Thread starter Al Campagna
  • Start date Start date
A

Al Campagna

I have a main form that represents the total length of a roll of fabric that
will be broken up into smaller pieces in an associated continuous subform.

In that subform, the records will be almost identical, from one to the
other. By that I mean... of the 15 fields, each new record added will have
dupe values in 12 to 14 of them.

When the user clicks the "Add a new Record", I would like to go to the
subform Last record, do a Copy of that record, move to the New record, and
paste that info into it. I can then set the user up to change those few
fields that differ (most of the time it will just be the Piece RollNo)

I just need some help with "programmatically" Copying and Pasting records in
AccessVB... "aircode" is fine.

Also, another quickie question. When I send the cursor (GotoControl) to a
text control, the data in the field is selected/highlighted by default.
What VB can I use to "deselect" the data, and have the cursor end up just
after the last character of the existing entry (the VB equivalent of the
"F2" shortcut key)
I want to avoid using SendKeys.

Thanks for any assistance you can offer,
 
Try this:

Me.subformname.SetFocus
DoCmd.GoToRecord , , acNewRec
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM
tabledrivingsubform")
With Me.subformname
!docid.Value = rs.Fields(0)
!docname.Value = rs.Fields(1).Value
!docpath.Value = rs.Fields(2).Value
!DocType.Value = rs.Fields(3).Value
'you may need to add more values here. this can
'also be done using and controls and indicies
'but this is a lot easier to read and
'understand.
End With
Set rs = Nothing
db.Close


-----Original Message-----
I have a main form that represents the total length of a roll of fabric that
will be broken up into smaller pieces in an associated continuous subform.

In that subform, the records will be almost identical, from one to the
other. By that I mean... of the 15 fields, each new record added will have
dupe values in 12 to 14 of them.

When the user clicks the "Add a new Record", I would like to go to the
subform Last record, do a Copy of that record, move to the New record, and
paste that info into it. I can then set the user up to change those few
fields that differ (most of the time it will just be the Piece RollNo)

I just need some help with "programmatically" Copying and Pasting records in
AccessVB... "aircode" is fine.

Also, another quickie question. When I send the cursor (GotoControl) to a
text control, the data in the field is
selected/highlighted by default.
 
Matt,
Thanks for the reply. I think I see what you're doing here... I'll give
it a try...
Thanks,
 
Back
Top