Copy contents of one record to another

P

Peter

I have a form into which a lot of repetitive data needs to
be entered. Often times, the difference between 3 or 4
records is only the sample ID number. I can set up a
macro to copy the previous record, realizing that I need
to edit the sample ID inorder to save it. However, as
soon as I move the cursor to that field, I get an error
message saying I need to change the data in that field,
which is what I'm trying to do but can't accomplish.

Anybody have any ideas? It appears that the record needs
to be edited before Access saves the copy but I'm not
certain how to do this...

Thanks,
Peter
 
J

John Vinson

I have a form into which a lot of repetitive data needs to
be entered. Often times, the difference between 3 or 4
records is only the sample ID number. I can set up a
macro to copy the previous record, realizing that I need
to edit the sample ID inorder to save it.

A better approach is to set the Default property of each field which
might be duplicated in the AfterUpdate event of the form. That way
when you move to a new record, the previous record's values appear as
the default in every field for which you've done this.

It's best to do this in VBA code, not a macro: something like (using
your own control names of course):

Private Sub Form_AfterUpdate()
Const Quote As String = """"
Me!txtX.Default = Quote & Me!txtX & Quote
Me!txtY.Default = Quote & Me!txtY & Quote
<etc>
End Sub
 
J

John Vinson

Unfortunately, while the repetitive records are not rare,
they don't occur frequently enough where I would want to
use default values. The user will be doing a good bit of
deleting...

I'd suggest, then, running a one-record Append query appending only
the fields that you want to dup. Could you post the steps of your
macro?
 

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