How do you determine if records already exist in a table?

WLC

Registered User.
Local time
Today, 10:16
Joined
Jun 19, 2012
Messages
63
I have a file that I want to import on a daily basis and append to an existing table in my database. The date changes each day. I want to create a query that checks to see if the date (of the first record) already exists before I import and append the new file. If it does, I want to show a message saying something to the effect of "This file has already been imported".
 
IMHO, Date is quiet not a UNIQUE identifier ! I think you might need a VBA Coded import method, rather than the built in method. As you need to use DCount to see if the data exist.
 
Really all I want to do is take the first record of my import file, use the date field, and scan the table that I want to import it into. If that date exists at all, I want to stop the import. Simple as that.
 
To see if a record exists, you construct criteria, like a where clause in a query, and count the records that satisfy those criteria. So to check if there is a record with #1/29/14# in the CreatedDate field, you could write a query like . . .
Code:
SELECT Count(*) FROM YourTable WHERE CreatedDate = #1/29/14#
. . . and use that to open a recordset, and read the value of the first field.

Alternatively, you can use the Access.Application.DCount() function, and to run the same count as above you would do . .
Code:
DCount("*", "YourTable", "CreatedDate = #1/29/14#")
hth
 

Users who are viewing this thread

Back
Top Bottom