key violations

G

Guest

When I append records from my form, I get a key violation error. I do not
have a primary key, and the allow zero length fields are set to no. The
Invoice# is set to no duplicates. Here is my SQL View:

INSERT INTO [Invoice Processing] ( VendorName, [Invoice#] )
SELECT Forms![Invoice Update Form]![Invoice Update SubForm]!VendorName AS
[Vendor Name], Forms![Invoice Update Form].[Invoice#] AS [Invoice#], *;

I can't figure out how to fix it. This append query if supposed to edit
fields already in the Invoice Procesing table.

Thanks
 
C

Craig Alexander Morrison

Why do you not have a Primary Key?

--
Slainte

Craig Alexander Morrison
Crawbridge Data (Scotland) Limited

Small Business Solutions Provider
 
G

Guest

1. Append queries add records to a table. They do not "edit fields already in
the Invoice Procesing table." Are you adding records or modifying existing
records?

2. Do you have a foriegn key field in this table linked to another table's
primary key?
 
J

John Spencer

Are you trying to insert ONE record into your table with the values on the
form? If so, you might try the alternative syntax for an insert query.
That could look something like the following. I'm not sure if you can refer
to a subform's control in a query.

INSERT INTO [Invoice Processing] ( VendorName, [Invoice#] )
VALUES (Forms![Invoice Update Form]![Invoice Update SubForm].Form!VendorName
, Forms![Invoice Update Form]![Invoice#])
 
G

Guest

1. I am using the append to add fields that do not have any data in them.
So, I would say that I am modifying the existing records.
2. I do not have a foreign key linked to any other table with primary key.

Jerry Whittle said:
1. Append queries add records to a table. They do not "edit fields already in
the Invoice Procesing table." Are you adding records or modifying existing
records?

2. Do you have a foriegn key field in this table linked to another table's
primary key?
--
Jerry Whittle
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

NayNay32 said:
When I append records from my form, I get a key violation error. I do not
have a primary key, and the allow zero length fields are set to no. The
Invoice# is set to no duplicates. Here is my SQL View:

INSERT INTO [Invoice Processing] ( VendorName, [Invoice#] )
SELECT Forms![Invoice Update Form]![Invoice Update SubForm]!VendorName AS
[Vendor Name], Forms![Invoice Update Form].[Invoice#] AS [Invoice#], *;

I can't figure out how to fix it. This append query if supposed to edit
fields already in the Invoice Procesing table.

Thanks
 
G

Guest

The SQL Statment is:
INSERT INTO [Invoice Processing] ( VendorName, [Invoice#] )
SELECT Forms![Invoice Update Form]![Invoice Update SubForm]!VendorName AS
[Vendor Name], Forms![Invoice Update Form].[Invoice#] AS [Invoice#], *;


Jerry Whittle said:
Also what's this in the SQL statement?
, *
--
Jerry Whittle
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


NayNay32 said:
When I append records from my form, I get a key violation error. I do not
have a primary key, and the allow zero length fields are set to no. The
Invoice# is set to no duplicates. Here is my SQL View:

INSERT INTO [Invoice Processing] ( VendorName, [Invoice#] )
SELECT Forms![Invoice Update Form]![Invoice Update SubForm]!VendorName AS
[Vendor Name], Forms![Invoice Update Form].[Invoice#] AS [Invoice#], *;

I can't figure out how to fix it. This append query if supposed to edit
fields already in the Invoice Procesing table.

Thanks
 
G

Guest

You can not use an append query to edit records. You need an update query to
do this. The SQL you provided in another post will only add records to the
table.
--
Jerry Whittle
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


NayNay32 said:
1. I am using the append to add fields that do not have any data in them.
So, I would say that I am modifying the existing records.
2. I do not have a foreign key linked to any other table with primary key.

Jerry Whittle said:
1. Append queries add records to a table. They do not "edit fields already in
the Invoice Procesing table." Are you adding records or modifying existing
records?

2. Do you have a foriegn key field in this table linked to another table's
primary key?
--
Jerry Whittle
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

NayNay32 said:
When I append records from my form, I get a key violation error. I do not
have a primary key, and the allow zero length fields are set to no. The
Invoice# is set to no duplicates. Here is my SQL View:

INSERT INTO [Invoice Processing] ( VendorName, [Invoice#] )
SELECT Forms![Invoice Update Form]![Invoice Update SubForm]!VendorName AS
[Vendor Name], Forms![Invoice Update Form].[Invoice#] AS [Invoice#], *;

I can't figure out how to fix it. This append query if supposed to edit
fields already in the Invoice Procesing table.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top