I have a loop that constantly checks a text file for modifications. On mod the data will be imported to a table via docmd.transfert ext. The problem is if another user (ftpuser) is uploading at the same time I get a 3051 error.
Is there a way to fail on error with no warning and restart the loop? This would be much easier if there was a way to get a return value out of docmd.transfert ext.
Here's my failed attempt. (FileExists() available at http://allenbrowne.com/func-11.html)
[CODE=vba]
Private Sub Form_Timer()
Dim strSQL As String
On Error GoTo Catch:
Catch:
If FileExists(strF ileToCheck) = True Then
If varFileDateTime <> FileDateTime(st rFileToCheck) Then
DoCmd.SetWarnin gs False
DoCmd.TransferT ext acImportDelim, "InHouseManImpo rtSpecs", "tbl_tempManife st", "c:\inetpub\ftp root\inhouseman .txt", False
DoCmd.OpenQuery "qry_ManifestUp dateAndInsert"
strSQL = "DELETE * FROM tbl_TempManifes t"
DoCmd.RunSQL strSQL
DoCmd.SetWarnin gs True
Me.txtUpdated.V alue = Now()
'MsgBox "The file has been modified!"
varFileDateTime = FileDateTime(st rFileToCheck)
Else
Me.txtActivity. Value = Now()
'MsgBox "The file is the same!"
End If
End If
End Sub[/CODE]
Thanks!
Is there a way to fail on error with no warning and restart the loop? This would be much easier if there was a way to get a return value out of docmd.transfert ext.
Here's my failed attempt. (FileExists() available at http://allenbrowne.com/func-11.html)
[CODE=vba]
Private Sub Form_Timer()
Dim strSQL As String
On Error GoTo Catch:
Catch:
If FileExists(strF ileToCheck) = True Then
If varFileDateTime <> FileDateTime(st rFileToCheck) Then
DoCmd.SetWarnin gs False
DoCmd.TransferT ext acImportDelim, "InHouseManImpo rtSpecs", "tbl_tempManife st", "c:\inetpub\ftp root\inhouseman .txt", False
DoCmd.OpenQuery "qry_ManifestUp dateAndInsert"
strSQL = "DELETE * FROM tbl_TempManifes t"
DoCmd.RunSQL strSQL
DoCmd.SetWarnin gs True
Me.txtUpdated.V alue = Now()
'MsgBox "The file has been modified!"
varFileDateTime = FileDateTime(st rFileToCheck)
Else
Me.txtActivity. Value = Now()
'MsgBox "The file is the same!"
End If
End If
End Sub[/CODE]
Thanks!
Comment