AndyLee100
Technical User
Hi all,
I am importing records into a database from a csv file and everything is working fine apart from one thing.
At the moment the code works by adding a record from the csv file into the database if it doesn't exist. The table it is importing into has a primary key on the Product Code and will fail if the record exists(Primary Key violation error). However this is ok as I am using On Error Resume Next to skip to the next record in the csv file.
What we need to do though is find if the record exists in the database and if it does check if the product description has changed or not. If it has changed then we need to edit the record and update it.
What I would like someone to advise me on is the most efficient way of finding if the record exists.
I can maybe think of a couple of ways. Like using the find method of the recordset object or having a separate function outside of the import loop that returns false if a select statement on the database with the product code returns no records.
I am sorry if I have rambled on a bit but I would really appreciate someone who has done this kind of thing before to advise me on the most efficient way the dealt with it.
Thanks in advance.
Andy
I am importing records into a database from a csv file and everything is working fine apart from one thing.
At the moment the code works by adding a record from the csv file into the database if it doesn't exist. The table it is importing into has a primary key on the Product Code and will fail if the record exists(Primary Key violation error). However this is ok as I am using On Error Resume Next to skip to the next record in the csv file.
What we need to do though is find if the record exists in the database and if it does check if the product description has changed or not. If it has changed then we need to edit the record and update it.
What I would like someone to advise me on is the most efficient way of finding if the record exists.
I can maybe think of a couple of ways. Like using the find method of the recordset object or having a separate function outside of the import loop that returns false if a select statement on the database with the product code returns no records.
I am sorry if I have rambled on a bit but I would really appreciate someone who has done this kind of thing before to advise me on the most efficient way the dealt with it.
Thanks in advance.
Andy