populating fields

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there any way to have a form come up, go to a new record, and then
populate some of the fields with the last record's information?

Thanks!
 
Hi, AT.

To duplicate the entire record, go to the last record, and then duplicate it
with the following code:

DoCmd.GoToRecord , , acLast
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append

or, if you only want certain fields copied, copy them to variables before
pasting them into a new record

' Go to last record, copy field values
DoCmd.GoToRecord , , acLast
f1 = Me!Field1
f2 = Me!Field2
... etc.
' Go to new record, paste field values
DoCmd.GoToRecord , , acNewRec
Me!Field1 = f1
Me!Field2 = f2
... etc.
' Put focus in the next field for data entry
Me!NextField.SetFocus

HTH
Sprinks
 
Back
Top