R
Ray
I use the following section of code to determine if there is a specific
folder in a location and the second section to see if there is anything in
the folder and how many items are there. It works great in 2003 but creates
an error in 2007. I have heard that 2007 does not support fso. Is there an
alternative to this code that will work? I understand enough to read the code
but not enough to write it myself.
fol = "\\mmpdsnas01a\apps$\Quality\Back Ends\VCAR Supporting Documents\" &
Me.[VCARNum]
Set fso = CreateObject("Scripting.FileSystemObject")
Dim Response
If Not fso.FolderExists(fol) Then
Response = MsgBox("Do you want Access to make a new folder named " &
vbCrLf & _
" " & Me.[VCARNum] & " to store the supporting
documents?", vbYesNo)
If Response = vbYes Then
fso.CreateFolder (fol)
Else
Exit Sub
End If
End If
*****************************
Dim FileNames
Set fs = Application.FileSearch
With fs
.LookIn = "\\mmpdsnas01a\apps$\Quality\Back Ends\VCAR Supporting
Documents\" & Me.[VCARNum]
.FileName = "*.*"
If .Execute > 0 Then
Me.Command44.Caption = .FoundFiles.Count & " Supporting Documents"
Me.Command44.ForeColor = vbBlack
Else
Me.Command44.Caption = "No Supporting Documents"
Me.Command44.ForeColor = vbRed
End If
End With
folder in a location and the second section to see if there is anything in
the folder and how many items are there. It works great in 2003 but creates
an error in 2007. I have heard that 2007 does not support fso. Is there an
alternative to this code that will work? I understand enough to read the code
but not enough to write it myself.
fol = "\\mmpdsnas01a\apps$\Quality\Back Ends\VCAR Supporting Documents\" &
Me.[VCARNum]
Set fso = CreateObject("Scripting.FileSystemObject")
Dim Response
If Not fso.FolderExists(fol) Then
Response = MsgBox("Do you want Access to make a new folder named " &
vbCrLf & _
" " & Me.[VCARNum] & " to store the supporting
documents?", vbYesNo)
If Response = vbYes Then
fso.CreateFolder (fol)
Else
Exit Sub
End If
End If
*****************************
Dim FileNames
Set fs = Application.FileSearch
With fs
.LookIn = "\\mmpdsnas01a\apps$\Quality\Back Ends\VCAR Supporting
Documents\" & Me.[VCARNum]
.FileName = "*.*"
If .Execute > 0 Then
Me.Command44.Caption = .FoundFiles.Count & " Supporting Documents"
Me.Command44.ForeColor = vbBlack
Else
Me.Command44.Caption = "No Supporting Documents"
Me.Command44.ForeColor = vbRed
End If
End With