473,326 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How do you duplicate records with a primary key?

My database is set up so people can input parts orders. Sometimes they
order the same parts on a monthly basis. I want to be able to duplicate
past parts orders and have it pasted in with a new primary key.

My first attempt seemed to work(minus a few Microsoft glitches). I used
a "duplicate" command button at first. This made a copy of the record
but failed to bump up the primary key by 1 number(so it seemed).
Actually, the number did change, it just failed to display it. If I
moved back one record then back to my copied record, the number would
be different. This only bugs me becuase I need to immediately print the
copied record once it is created. The wrong primary key is displayed
when I print unless I scroll through the records before hand. This
doesn't bother me that much but I have about 10 people who use this
database (some remotely) and they get confused on this kind of stuff so
to avoid lengthy phone calls on how to use computer stuff (which I
don't get paid for) I decided not to spread the word on how to do it.

Now...as of today, it doesnt work at all. When I duplicate the record,
I get an error and it pastes the data to a "paste errors" table. (How
do I find out what the error was?)

All I need is the ability to duplicate a record from a form and have
that record appear with a new primary key.(I call them AP numbers)

Nov 13 '05 #1
2 3206
Sounds like your problem to solve is:

"create a duplicate a purchase order or invoice and give it a new PO or
invoice number?"

If this is the problem, then in a transaction
- begin transaction
- generate a new invoice number
- write the header record, using the new invoice number as the primary key
- if needed, put the old/previous invoice number in the new header
record's information to create a chain of references to past information
- write all the detail records using the new invoice number
- commit transaction

On Error then
Rollback transaction
Display error message
PS in a multiple user environment,
- when creating a new primary key
- have the most recent key created in a table
- read the table with DenyRead and update the value
- if denied read then loop until can read
HTH,

John Bickmore

"stranger" <th***@hotmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
My database is set up so people can input parts orders. Sometimes they
order the same parts on a monthly basis. I want to be able to duplicate
past parts orders and have it pasted in with a new primary key.

My first attempt seemed to work(minus a few Microsoft glitches). I used
a "duplicate" command button at first. This made a copy of the record
but failed to bump up the primary key by 1 number(so it seemed).
Actually, the number did change, it just failed to display it. If I
moved back one record then back to my copied record, the number would
be different. This only bugs me becuase I need to immediately print the
copied record once it is created. The wrong primary key is displayed
when I print unless I scroll through the records before hand. This
doesn't bother me that much but I have about 10 people who use this
database (some remotely) and they get confused on this kind of stuff so
to avoid lengthy phone calls on how to use computer stuff (which I
don't get paid for) I decided not to spread the word on how to do it.

Now...as of today, it doesnt work at all. When I duplicate the record,
I get an error and it pastes the data to a "paste errors" table. (How
do I find out what the error was?)

All I need is the ability to duplicate a record from a form and have
that record appear with a new primary key.(I call them AP numbers)

Nov 13 '05 #2
Sorry dude, your talking crazy. I know the process, I just need a
solution. Something like a command button, or macro or something.

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: JStrummer | last post by:
I just put together a PHP mailing list sign-up page that posts to a mySQL DB. The PHP script prevents INSERTs when the email address is already located in the database. Problem: I need to import...
9
by: Catherine Jo Morgan | last post by:
Can I set it up so that a certain combination of fields can't contain the same entries, on another record? e.g. a combination of FirstName/LastName/address? Or FirstName/LastName/phone? Or...
2
by: ms | last post by:
Access 2000: I am trying to delete duplicate records imported to a staging table leaving one of the duplicates to be imported into the live table. A unique record is based on a composite key of 3...
5
by: Manish | last post by:
The topic is related to MySQL database. Suppose a table "address" contains the following records ------------------------------------------------------- | name | address | phone |...
0
by: B.N.Prabhu | last post by:
Hi, I have a DataTable with several rows. Its having 20 Columns. when i click the Insert button then i have to check the Database Rows. Whether these new rows are already available in the...
0
by: claus | last post by:
Hi, I am not a programmer but tries anyway to program a feature in a form where I am able to copy entries for the form and a subform. I have tried follow the guide here...
2
by: mivey4 | last post by:
Okay I have 2 tables: Table A - holds a list of new hardware serial numbers and their corresponding model (no constraints or indexes) Table B - holds a distinct list of current serial numbers...
1
by: colin-whitehead | last post by:
I have 2 tables tblReports primary key UPN, plus numeric fields Effort, Attain, etc tblComments numeric primary key ID & textfield Text In the Query I select each record from tblReports...
1
by: xraive | last post by:
I have a problem with this. Currently I am trying Allen's code and i am not successful. Current Design Table1 (Main Form) TravelID (PK) ApprovedBY EntreredBy BudgetCode ExpenseCode
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.