Re: Allen Brownes Copying forms/Subforms

Tech-Archive recommends: Fix windows errors by optimizing your registry



Is OrderID the primary key?

If so, omit the line:
!OrderID=Me.OrderID

You want to duplicated order to have a new number, don't you?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Ron Weaver" <RonWeaver@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E737A353-ACB8-4B73-BF8C-176472888BB6@xxxxxxxxxxxxxxxx
I checked my tables. All tables are "Duplicates OK", except for the primary
keys like "OrderID". All of my primary keys are autonumber.

I entered a new order manually. That works fine.

The only things marked unique in the indexes were the primary keys.

I copied your code to my program and put all the fields from the main
form:
!OrderID=Me.OrderID
!FirstName=Me.FirstName
!LastName=Me.LastName
Etc.

I don't know what I've done wrong here.
Thanks for trying
"Allen Browne" wrote:

Duplicate suggests Access is trying to assign the same autonumber again,
or
perhaps the duplicate is on another field where you specified a "No
Duplicates" index?

Presumably you are not assigning a value to the OrderID. Try adding a new
record to the table manually. If this also fails, post back for a fix for
this bug.

If it is not the autonumber, open the table in design view, and open the
Indexes dialog (View menu). Look through the list in the dialog to see
what
else might be marked Unique.

"Ron Weaver" <RonWeaver@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:198DDC6F-75C0-4E92-B803-A4EC4E545680@xxxxxxxxxxxxxxxx
Allen
Thanks for your help. The reference was set to 2.1. I changed it to DOA
3.6.
I also looked at my Orders Table "OrderID" to be sure it was on auto
number.
It was. I am still getting the error message #3022: Not successful
because
it
would create duplicate values in the index, primary key, or
relationship.
I
will double check everything again tomorrow. I did have LNGID in there.
Thanks again for your help.
Ron

"Allen Browne" wrote:

If the AddNew line fails, choose References on the Tools menu (from
the
code
window), and make sure you have the box checked next to:
Microsoft DAO 3.6 Libraray

The code uses a variable named LNGID, not 1NGID.

The code assumes OrderID is an AutoNumber. If it is, and the Update
succeeded, it will not be Null. If it is not an autonumber, you need
to
work
on your table, as you seem to have a number field that is (presumably
primary key) but the save worked without assigning a value to it.

"Ron Weaver" <RonWeaver@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E72FBBC1-E57C-42D7-B1AC-5D2B8F86B0CF@xxxxxxxxxxxxxxxx
I am a newby with access, but have actually created a
Customer/Orders
program that works well. Tables are: Orders, Products, Order
Details,
and
Customers. I inserted Allen's code found at
"http://allenbrowne.com/ser-57.html"; into the Northwind data base
and
it
worked perfectly. I followed his instructions as best I could but
the
code
hung up at the ".addNew". When I put the "OrderID" in there the
error
says
that it can't duplicate the field and since it is a primary field, I
can't
click the Duplicate OK in the Table Design Field. When I remove the
"OrderID"
from the .addNew, the code proceeds to the 1ngID=OrderID and stops
because
there is a null?? I hope that maybe Allen or someone out there can
give
me
some insight on this. This is all I need to finish my program. I
know
I'm
over my head here. Thanks for any help.


.



Relevant Pages

  • Re: Allen Brownes Copying forms/Subforms
    ... Allen Browne - Microsoft MVP. ... into the Customer and OrderDetails tables, creating a new OrderID number, ... The only things marked unique in the indexes were the primary keys. ... perhaps the duplicate is on another field where you specified a "No ...
    (microsoft.public.access.modulesdaovba)
  • Re: Allen Brownes Copying forms/Subforms
    ... Allen Browne - Microsoft MVP. ... into the Customer and OrderDetails tables, creating a new OrderID number, ... The only things marked unique in the indexes were the primary keys. ... perhaps the duplicate is on another field where you specified a "No ...
    (microsoft.public.access.modulesdaovba)
  • Re: Allen Brownes Copying forms/Subforms
    ... Allen Browne - Microsoft MVP. ... into the Customer and OrderDetails tables, creating a new OrderID number, ... The only things marked unique in the indexes were the primary keys. ... perhaps the duplicate is on another field where you specified a "No ...
    (microsoft.public.access.modulesdaovba)
  • Re: Allen Brownes Copying forms/Subforms
    ... The "OrderID" is the primary key. ... Allen Browne - Microsoft MVP. ... perhaps the duplicate is on another field where you specified a "No ...
    (microsoft.public.access.modulesdaovba)
  • Re: Allen Brownes Copying forms/Subforms
    ... perhaps the duplicate is on another field where you specified a "No ... Presumably you are not assigning a value to the OrderID. ... If it is not the autonumber, open the table in design view, and open the ... would create duplicate values in the index, primary key, or relationship. ...
    (microsoft.public.access.modulesdaovba)