Preventing duplicates in Access table

  • Thread starter Thread starter little_rascals
  • Start date Start date
L

little_rascals

Hi,

I need to import data from a text file everyday. With a
command button, i can auto import those data from the text
file into my access table. However, how can i prevent the
same set of data from being imported into the access table
if the user accidentally click on the command button more
than once?

Pls help! Thank You!!
 
If you have to overwrite records with new info, than just the key field will not help. What I usually do is run a delete query first that removes all like records and then the append query to replace old and add new ones.

Hope this helps.
 
Hi,

I need to import data from a text file everyday. With a
command button, i can auto import those data from the text
file into my access table. However, how can i prevent the
same set of data from being imported into the access table
if the user accidentally click on the command button more
than once?

Pls help! Thank You!!

Is there anything in the text file itself which would indicate a
duplicate - any field or combination of up to ten fields?

If so, open the Table in design view. Select the Indexes tool (looks
like a lightning bolt hitting a datasheet... an attractive thought
sometimes!); type some unique name in the left column (idxPreventDups
maybe), and select that field or those fields on consecutive rows in
the right column. Specify that this index is Unique.

Now any records which duplicate existing records will be rejected with
a (trappable) error message.
 

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

Back
Top