Key violation problem when i import the text file

D

dingchi88

Hi:

I create a table with 5 field without any records, and i want to
import a text file to update the table. I have a field "ID" which is
primary key for the table, i set it to be "autonumber". When i import
the external file, it says "error due to key violation".and only a few
records can be imported to the table, and it does not create the
primary key for it.

It works pretty well in 97 version, i just converted it to 2003
version,


Anybody can help?!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
G

Golfinray

If you are trying to create a key when a key is already there, that won'
work. Go the design view of the table, remove the key, set the field types
for your records, and then try and import. Or import the file, then go in and
set or reset the key and name the fields and types as needed.
 
D

dingchi88

If you are trying to create a key when a key is already there, that won'
work. Go the design view of the table, remove the key, set the field types
for your records, and then try and import. Or import the file, then go in and
set or reset the key and name the fields and types as needed.


yes that's rite. but i want Access to create it automatically. is
that possible when i import the file.
bcuz it works in 97 version, i suppose there must be a way to do that
in 2003.

for instance: the import file is :
2008401 333 222 110
2008401 333 222 111
2008401 333 222 112
2008402 333 222 113

when i import this in 97version, it automatically create the PK. looks
like:
KEY DATE NUM NUM NUM
1 2008401 333 222 110
2 2008401 333 222 111
3 2008401 333 222 112
4 2008402 333 222 113

But it doesnt work in 2003. Do you know how to fix this?
 
G

Golfinray

Delete the key you have now and when you import it will ask if you to allow
access to create a key. Say yes and it will create an autonumber field, but
not if one is already there.
 
D

dingchi88

Delete the key you have now and when you import it will ask if you to allow
access to create a key. Say yes and it will create an autonumber field, but
not if one is already there.

Thank you a lot ........
do you mind just one more question..

i just want a form to support several parameters for report.it has
nothing to do wi query.
for example: i want the user to enter the parameter when they open the
report, then what they entered directly go into the specific place i
specify.
For the original one i just put something like "=[Enter the Invoice
Number]"

"=[Enter the beginning date]"

"=[Enter the ending date]" at different place in report.
I just want a form to support several parameters. I use " Forms!
[input]![Label1]"

" Forms![input]![Label2]"..........however it doesnt work..



Really thx for your help!!!!!!!
 
G

Golfinray

I think you need =forms![input].label2

Delete the key you have now and when you import it will ask if you to allow
access to create a key. Say yes and it will create an autonumber field, but
not if one is already there.

Thank you a lot ........
do you mind just one more question..

i just want a form to support several parameters for report.it has
nothing to do wi query.
for example: i want the user to enter the parameter when they open the
report, then what they entered directly go into the specific place i
specify.
For the original one i just put something like "=[Enter the Invoice
Number]"

"=[Enter the beginning date]"

"=[Enter the ending date]" at different place in report.
I just want a form to support several parameters. I use " Forms!
[input]![Label1]"

" Forms![input]![Label2]"..........however it doesnt work..



Really thx for your help!!!!!!!
 
J

Jeff Boyce

A caveat about deleting a Primary Key/autonumber field ...

If that Primary Key is used in any other tables (as a foreign key), deleting
the field will "orphan" those related records in the other tables.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

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