Hello guys,
I've been looking for a solution on this for quite a while now and wasn't able to find a way around thus far:
Simply put, I have an Access frontend database where I get a bunch of text files imported everyday, data is later used in Excel. As the files are generated from the backend in the same directory with names according to date, I have a form to import only the files with the dates I need. No big deal if I hadn't had a number of users that "forget" they have already imported the files and duplicate the whole thing.
No expert VBA and SQL dev, assuming I have a table to log which files I've already imported, I've been trying to get a message box to pop up with the following piece of code (relevant code below, of a lot of things done in the process):
********************
NAME_FILE_1 = "File_" & DATA_FORM & ".TXT" 'File that I'm getting from the network
Set DUPLI = BD.OpenRecordset("SELECT NAME_FILE FROM TLOTE WHERE NAME_FILE='" & NAME_FILE_1 & "'") 'TLOTE is the table where the log is, trying to look there if the file has already been imported
If NAME_FILE_1 = DUPLI Then 'Runtime errors happening here
MsgBox ("The file has already been imported.")
Else
MsgBox ("Bring it on.")
End If
********************
I was expecting it would work just fine, but I'm obviously wrong about how the SQL select is set onto DUPLI, runtime errors 13 or 3001 unfold depending on some different SQL statements I try.
Any help appreciated.
Thanks. Caio
I've been looking for a solution on this for quite a while now and wasn't able to find a way around thus far:
Simply put, I have an Access frontend database where I get a bunch of text files imported everyday, data is later used in Excel. As the files are generated from the backend in the same directory with names according to date, I have a form to import only the files with the dates I need. No big deal if I hadn't had a number of users that "forget" they have already imported the files and duplicate the whole thing.
No expert VBA and SQL dev, assuming I have a table to log which files I've already imported, I've been trying to get a message box to pop up with the following piece of code (relevant code below, of a lot of things done in the process):
********************
NAME_FILE_1 = "File_" & DATA_FORM & ".TXT" 'File that I'm getting from the network
Set DUPLI = BD.OpenRecordset("SELECT NAME_FILE FROM TLOTE WHERE NAME_FILE='" & NAME_FILE_1 & "'") 'TLOTE is the table where the log is, trying to look there if the file has already been imported
If NAME_FILE_1 = DUPLI Then 'Runtime errors happening here
MsgBox ("The file has already been imported.")
Else
MsgBox ("Bring it on.")
End If
********************
I was expecting it would work just fine, but I'm obviously wrong about how the SQL select is set onto DUPLI, runtime errors 13 or 3001 unfold depending on some different SQL statements I try.
Any help appreciated.
Thanks. Caio