Verify file exists before executing TransferText

G

Guest

How can I verify that a file exists before I execute the TransferText. I
would like a message to display if the file that I am trying to import does
not exist.

Here is my command:
DoCmd.TransferText acImportDelim, _
"Dailyrpt Import Specification", _
"Dailyrpt", _
[Forms]![Menu]![Path2] & "/dailyrpt.txt"

It works perfectly as long as the dailyrpt.txt file is present. If the file
isn't there, the user needs to know that via a message.

Thanks!
 
P

PieterLinden via AccessMonster.com

How can I verify that a file exists before I execute the TransferText. I
would like a message to display if the file that I am trying to import does
not exist.

Here is my command:
DoCmd.TransferText acImportDelim, _
"Dailyrpt Import Specification", _
"Dailyrpt", _
[Forms]![Menu]![Path2] & "/dailyrpt.txt"

It works perfectly as long as the dailyrpt.txt file is present. If the file
isn't there, the user needs to know that via a message.

Thanks!

before the DoCmd...

Dim strDirectory As String
Dim strFile As String
Dim strFullPath as String

strDirectory = Me.txtItemToAdd
strFile = Dir(strDirectory & "\*.csv")
' or...
' strFullPath = strDirectory & "\" & strFile
If strFile <> ""
DoCmd.TransferText acImport....
else
Msgbox "Something's wrong!"
End If
 
A

Anssister Ring

How can I verify that a file exists before I execute the TransferText. I
would like a message to display if the file that I am trying to import does
not exist.

Here is my command:
DoCmd.TransferText acImportDelim, _
"Dailyrpt Import Specification", _
"Dailyrpt", _
[Forms]![Menu]![Path2] & "/dailyrpt.txt"

It works perfectly as long as the dailyrpt.txt file is present. If the file
isn't there, the user needs to know that via a message.

Thanks!
 

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