Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Performing an action when a file is written by another Application

Status
Not open for further replies.

MarkRobinson

Programmer
Feb 18, 2000
112
US
An industrial machine puts a .TXT file in a specified folder from time to time. I want Access2000 to import whenever that file appears. <br>Potential problem: I don't want to try to import while the file is being written.<br>Ideas would be appreciated.<br>Thanks
 
Well, you could put a timer on a form to check a folder from time to time.<br>And use the &quot;Dir&quot; function to see if that file exists.<br>Is the size of the file constant (everthime it's written its the same?)<br><br>Public Sub GetFile()<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim MyFile, MyPath, MyName<br>&nbsp;&nbsp;&nbsp;&nbsp;' In Microsoft Windows:<br>&nbsp;&nbsp;&nbsp;&nbsp;' Returns &quot;WIN.INI&quot; if it exists.<br>&nbsp;&nbsp;&nbsp;&nbsp;MyFile = Dir(&quot;C:\WINDOWS\WIN.INI&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;If MyFile Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferText acImportDelim, &quot;SpecName&quot;, &quot;TableName&quot;, MyFile<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' delete file so it won't be there later when timer looks again.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Kill MyFile<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>End Sub<br> <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
Thanks!<br>No.. the file size isn't consistent... nor is the filename. The File extension is the only given and I'm having trouble with the Dir Command... I posted another message about the Dir command.<br>Do you know of a way I could avoid trying to read the file while it is being written?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top