Duplicate A Record

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

I have a sub-form, which is in datasheet view.
What I would like to do is click on the record selector in
the sub-form and then press a button, which duplicates the
record in the sub-form. I assume that the sub-form will
have to be re-queried to see the record after duplication.
I have tried creating a duplicate record, command button,
on the main form using the wizard but I can't get it to
work.
Can anyone assist?

Nick
 
suggest you write an Append query, appending the table to itself. set the
criteria for the primary key fields as
Forms!MainFormName!SubFormControlName!NameOfPrimaryKeyFieldInSubform

this way you will only append the currently selected record in the subform.
make sure you *don't* append the primary key field. also note, this will not
work if you have any unique keys other than the primary key.

hth
 
Thanks, I'll give it a go.
Regards
Nick
-----Original Message-----
suggest you write an Append query, appending the table to itself. set the
criteria for the primary key fields as
Forms!MainFormName!SubFormControlName! NameOfPrimaryKeyFieldInSubform

this way you will only append the currently selected record in the subform.
make sure you *don't* append the primary key field. also note, this will not
work if you have any unique keys other than the primary key.

hth





.
 
Hi Tina,
Your suggestion worked a treat, Thanks.
Is there any way of having access highlight one of the
fields of the new record?
In my case I want to change the date of the new record so
it would be time saving if the date field was selected so
I only have to over type it.

Regards
Nick
 
are you appending the data field in the Append query? unless that field in
the table is set to Required = Yes, you can just "not append" the date.
also, are you entering a standard default value, such as today's date? if
so, you can set that up in the Append query so you don't have to make the
change manually.
failing all that, try the following:
in Tools, Options, Keyboard tab, Behavior Entering Fields section, choose
Select Entire Field. i believe that's the default setting, but am not sure.
in your procedure, after the code that runs the query then requeries the
subform and takes you to the new record, add a SetFocus action to take you
to the date field. that should do it.
in fact, if you simply put an input mask on the date field, your input
should overwrite the existing data, even if the value is not highlighted -
because it has nowhere else to go, so to speak.

hth
 
Back
Top