error execution 13 (1 Viewer)

habiler

Registered User.
Local time
Today, 15:35
Joined
Aug 10, 2014
Messages
70
Hello all,

The module below below gives e an error of execution 13, while it worked perfectly in another directory. The error is situated at the level of the line:

Code:
 If Len(Dir(filePath)) > "" Then
We can help me?

Thanks for all

Habiler

The whole module :

Code:
Private Sub Décision_DblClick(Cancel As Integer)
  Dim filePath As String
  filePath = "P:\X\Y\Doc" & Me.Decision & ".pdf"
  
'  Debug.Print filePath
'  Debug.Print Dir(filePath) ' will print the filename if found, blank line if not found
  
  If Len(Dir(filePath)) > "" Then
      Me.tt = filePath
    Refresh
  Else
  Debug.Print filePath
  Debug.Print Me.tt
    MsgBox "Le fichier" & filePath & "n'existe pas. Veuillez le scanner et l'enregistrer"
  End If
  End Sub
 

Grumm

Registered User.
Local time
Today, 15:35
Joined
Oct 9, 2015
Messages
395
You get this error because you try to check if any number is bigger than ""
So the code ask you nicely what you really expect by doing this kind of comparison.
 

MarlaC

Registered User.
Local time
Today, 09:35
Joined
Aug 1, 2013
Messages
82
Grumm has it right. Len() is going to give a numeric result every time, so you should be checking to see if Len >0, not empty string.
 

Users who are viewing this thread

Top Bottom