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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2010 Filesearch replacment

Status
Not open for further replies.

razchip

Technical User
Feb 2, 2001
133
US
I had a filesearch function in Access 2000, I've tried various things in 2010 and have had no luck. I look to see if a trigger file exist, if it does the program proceeds, if not, I show a warning and close the process (shown below). Is there an easy method to do this in 2010?

Set fs = Application.FileSearch
'Looks for the trigger file before it copies the files to C:\xxxxxx
With fs
.Lookin = "\\Path\CCCC\VVVV\BBBBB\NNNNNN"
.FileName = "K6empsts.trg"

If .Execute > 0 Then
Else
'DoCmd.OpenForm "NoTrigger", acNormal, acPreview
End If

Thanks.

Thanks for the help.
Greg
 
If your wanting to verify whether a file exists or not, and the move if it doesn't exist, then you could do something like:
Code:
Sub MoveMyStuff
   Dim f1 as String 'orig file path
   Dim f2 as String 'new file path

   f1 = "C:\MyNewFile.txt"
   f2 = "H:\MyFolderName\AnotherSubfolder\MyNewFile.txt"

   If Dir(f2) = "" Then 'File is not there, go ahead and move
      FileCopy f1, f2 'copy the file
   Else
      kill f2 'delete existing file
      FileCopy f1, f2 'copy the file
   End If
End Sub

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top