A
ArielZusya
I thought I had solved this problem earlier but apperently not. I'm getting
the following error:
The changes you requested to the table were not successful because they
would create duplicate value in the index, primary key, or relationship.
Change the data in the fields that contain duplicate data, remove the index,
or redefine the index to permit duplicate entries and try again.
Here's the INSERT Query I'm using:
INSERT INTO tblRefNum ( RefNum, BatchNum )
SELECT DISTINCT RefNum, {lngBatch}
FROM tblMain;
{lngBatch} is a number I generate using VBA which looks at tblRefNum for the
highest BatchNum in the table and adds 1 to it so if I've never added a
record to tblRefNum lngBatch would be 1, and if this is the second time I've
added a record to tblRefNum lngBatch would be 2. I use the insert query
every time I import an excel spreadsheet into tblMain. The excel spreadsheet
has FirstName, LastName, and RefNum. Every FirstName and LastName in a given
spreadsheet being imported has the same RefNum as the others in that
spreadsheet. That's why the insert query looks for Distinct values in
tblMain. In other words the spreadsheet looks like this:
FirstName LastName RefNum
Joe Smith 54CBF6267
Jane Doe 54CBF6267
etc.
It then inserts that case name into tblRefNum with the BatchNum as described
above. I'm worried that this query does nothing to determine if the unique
values found in tblMain are already in tblRefNum. If this is the first time
I've run the query, the query would only find one RefNum so it wouldn't have
any problems. But, if this is the second or third or later time, it would
find more RefNums. What do I do? In case it's helpful, here's my table
structures:
tblMain.ID_Main, AutoNumber, PrimaryKey
tblMain.FirstName, Text
tblMain.LastName, Text
tblMain.RefNum, Text
tblRefNum.RefNum, Text, PrimaryKey
tblRefNum.BatchNum, Number, PrimaryKey
tblRefNum.Description, Text
There is a one-to-many relationship between tblRefNum.RefNum and
tblMain.RefNum. Thanks for your help!
the following error:
The changes you requested to the table were not successful because they
would create duplicate value in the index, primary key, or relationship.
Change the data in the fields that contain duplicate data, remove the index,
or redefine the index to permit duplicate entries and try again.
Here's the INSERT Query I'm using:
INSERT INTO tblRefNum ( RefNum, BatchNum )
SELECT DISTINCT RefNum, {lngBatch}
FROM tblMain;
{lngBatch} is a number I generate using VBA which looks at tblRefNum for the
highest BatchNum in the table and adds 1 to it so if I've never added a
record to tblRefNum lngBatch would be 1, and if this is the second time I've
added a record to tblRefNum lngBatch would be 2. I use the insert query
every time I import an excel spreadsheet into tblMain. The excel spreadsheet
has FirstName, LastName, and RefNum. Every FirstName and LastName in a given
spreadsheet being imported has the same RefNum as the others in that
spreadsheet. That's why the insert query looks for Distinct values in
tblMain. In other words the spreadsheet looks like this:
FirstName LastName RefNum
Joe Smith 54CBF6267
Jane Doe 54CBF6267
etc.
It then inserts that case name into tblRefNum with the BatchNum as described
above. I'm worried that this query does nothing to determine if the unique
values found in tblMain are already in tblRefNum. If this is the first time
I've run the query, the query would only find one RefNum so it wouldn't have
any problems. But, if this is the second or third or later time, it would
find more RefNums. What do I do? In case it's helpful, here's my table
structures:
tblMain.ID_Main, AutoNumber, PrimaryKey
tblMain.FirstName, Text
tblMain.LastName, Text
tblMain.RefNum, Text
tblRefNum.RefNum, Text, PrimaryKey
tblRefNum.BatchNum, Number, PrimaryKey
tblRefNum.Description, Text
There is a one-to-many relationship between tblRefNum.RefNum and
tblMain.RefNum. Thanks for your help!