Populating new record by copying last record

P

Peter

I have a table tha contains many memo fields.
When I create a new record most times I have to change minor data in each
field. Thus I don't have to retype or paste all of the information over.

How can I create a command button that will pull the info from the last
record or a standard Template.

Thank you in advance
Peter
 
S

Steve Schapel

Peter,

I think running an Append Query to add a new record with the required
data would work well here. However, if this will be based on the "last
record", you will need to have a data-based way of determining what the
last record is, i.e. an incremental ID field or some such, or a
DateCreated field. For example...
CurrentDb.Execute "INSERT INTO YourTable ( Field1, Field2, etc )" & _
" SELECT Field1, Field2, etc FROM YourTable" & _
" WHERE ID In (SELECT Max([ID]) FROM
YourTable)", dbFailOnError
Me.Requery

If you mean you will be entering multiple records in the one session, an
alternative approach may be to hold the most recently entered values for
each field in string variables, and then assign them to the controls on
the new record via the button's Click event.

For example, in the Declarations section of the form...
Dim Field1Holder As String
Dim Field2 Holder As String
etc

Then on the After Update event of Field1 (etc) ...
Field1Holder = Field1

Then on the Click event of the button...
Field1 = Filed1Holder
Field2 = Filed2Holder
etc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top