Help - Need to duplicate record using code (Trying Again)

  • Thread starter Thread starter Jody
  • Start date Start date
J

Jody

I'm fairly inexperienced when it comes to VBA. Could
someone please provide some suggestions on how to
duplicate the current record and at the same time change
the date field to indicate the next day. See my previous
post below.
********************************
I have created a travel itinerary database for our sales
reps to use. A simple data entry screen contains the
following information: SalesRep, Date, CustName,
CustCity, CustState, Activity, Purpose, and Comments with
a subform imbedded containing fields to collect individual
contact info: ContactName, ContactTitle, ContactPhone.

Many times our reps would like to "copy" a record to
cover a time period anywhere from 2-5 days or more. They
do not like to keep typing the same information each day.
Is there a way to create a "duplicate record" button and
at the same time have the date automatically be
incremented by one day?

Would appreciate any help you can give.
Thank you!


...


..
 
Jody, I presume your table has a Primary Key, as in the example below
the PKey on APInvoices is APInvoiceID ...
If the PKey is Auto incrementing then don't include it in the Insert
STATEMENT. as in what I did. The database will do it. If not, then work
it out and include it in the insert list.

See where ,,, [PaymentDate]+3 AS PayDate will be inserted into the NEW
record as the PaymentDate field

+ 3 means ADD 3 days.


good luck..

INSERT INTO APInvoices ( PaymentDate, CompanyID, InvoiceNumber ) SELECT
[PaymentDate]+3 AS PayDate, APInvoices.CompanyID, APInvoices.InvoiceNumber
FROM APInvoices
WHERE (((APInvoices.APInvoiceID)=200));

so create a string out of the above and then use currentdb.execute "your
string var"

then requery the subform,

(e-mail address removed)

who loves ya..
 
Back
Top