| re: How do you duplicate records with a primary key?
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" <thepl@hotmail.com> wrote in message
news:1109889738.530563.304910@g14g2000cwa.googlegr oups.com...[color=blue]
> 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)
>[/color] |