473,698 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3231
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.goo glegroups.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
2982
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 some flat-files that stored the signups, prior to this new form. Email addresses weren't checked, so there are a lot of records that have the same email address. Once I import these into the table, how would I go about putting together a SQL...
9
14579
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 FirstName/LastName/email? Or is it possible to allow this but to throw up an alert message? Warning that this person is probably already in the database? TIA
2
4984
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 fields (vehicleID, BattID, and ChgHrs). VehicleID and BattID are a TEXT datatype and ChrHrs are a number(long int.) datatype. Since records to be imported can have duplicate records of the composite key I need to clean all but one of the...
5
3989
by: Manish | last post by:
The topic is related to MySQL database. Suppose a table "address" contains the following records ------------------------------------------------------- | name | address | phone | ------------------------------------------------------- | mr x | 8th lane | 124364 | | mr x | 6th lane | 435783 | | mrs x | 6th lane | 435783 |
0
2105
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 Database. If its there, then i need to seperate the Duplicate Records Based upon 4 columns(EmployeeID, ProjectName, ProjectType, StartTime -- should be activate as a Composite Primary key)
0
2516
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 http://allenbrowne.com/ser-57.html, but my problem is that I have more than one keyfield in the join between the two tables: Hovedoplysninger and Itemoplysninger. The tree fields are: "Medarbejder", "Sagsnummer" and "Mandag". I have succeded creating the new entry...
2
45864
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 and the corresponding model numbers (primary key on serial_numbers) Since Table A has no constraints duplicates may exist. Additionally, table A is actually an Excel spreadsheet that is maintained by an employee that records new hardware as...
1
2909
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 using UPN and for each of the numeric fields use DLookup to look up the Text in tblComments. the expression DLookUp("Text","tblComments","ID=" & tblReports!Effort)
1
7268
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
8611
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8904
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.