code issues in 2007

R

Ray

I have a database in Access 2000 format.
Some of out computers have been upgraded to Runtime 2007.
All works well except the following code. Runtime 2007 sees it is a "illegal
operation" and shuts down. It works fine in all other versions of Runtime and
Access.
The code is supposed to count the files in a folder and display the file
count in the caption of a command button.
Any Suggestions?

Dim FileName
Set fs = Application.FileSearch
With fs
.LookIn = "\\mmpdsnas01a\apps$\Quality\Specialty\DMR Supporting
Documents\" & Me.[DMR #]
.FileName = "*.*"

If .Execute > 0 Then

Me.Command222.Caption = .FoundFiles.Count & " Supporting Documents"
Me.Command222.ForeColor = vbBlack

Else
Me.Command222.Caption = "No Supporting Documents"
Me.Command222.ForeColor = vbRed

End If

End With
 
M

Maurice

application.filesearch is no longer an option in Access 2007. You have to use
the FileSystemObject to perform the actions you want to do.
 
D

Dirk Goldgar

Ray said:
I have a database in Access 2000 format.
Some of out computers have been upgraded to Runtime 2007.
All works well except the following code. Runtime 2007 sees it is a
"illegal
operation" and shuts down. It works fine in all other versions of Runtime
and
Access.
The code is supposed to count the files in a folder and display the file
count in the caption of a command button.
Any Suggestions?

Dim FileName
Set fs = Application.FileSearch
With fs
.LookIn = "\\mmpdsnas01a\apps$\Quality\Specialty\DMR Supporting
Documents\" & Me.[DMR #]
.FileName = "*.*"

If .Execute > 0 Then

Me.Command222.Caption = .FoundFiles.Count & " Supporting Documents"
Me.Command222.ForeColor = vbBlack

Else
Me.Command222.Caption = "No Supporting Documents"
Me.Command222.ForeColor = vbRed

End If

End With


FileSearch is not supported in A2007, but David Fenton just posted a class
module to reproduce its functionality. Look in the Access General Questions
newsgroup (microsoft.public.access) for a post with the subject, "NEW: Class
Module Replacement for Office FileSearch Object", dated 5/26/2009, by David
W. Fenton. Or use Google Groups to search for it.
 

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