Check for folder based on field name

LouiseRose74

New member
Local time
Today, 19:03
Joined
Dec 16, 2011
Messages
2
Hi

I'm currently upgrading the companies tooling database and was asked to add a button to various forms to point to the file Dir for the tool number selected. I've managed do that, but I would like to hide the button if the folder does not exist. I'm not much good when it comes to VB, got the ideas but not the tallent, see code below :)
The value im trying to check against is a field called CHHToolNumber

Code:
Dim MyDir As String
MyDir = Dir("N:\4. Maintenance\Tooling Information\", vbDirectory)
If MyDir = "me.CHHToolNumber" Then
MsgBox ("Pass")
Else
MsgBox ("Fail")
End If
End Sub

Its not vital. Just trying to save users from clicking the link and wasting time.

Thanks in advance
Louise
 
The function dir has as a result the first folder or file name, the next time calling dir the next file or folder is returned. The way you are checking for the folder existance does not work for this reason, try:

Code:
If dir("N:\4. Maintenance\Tooling Information\" & me.CHHToolNumber, vbDirectory) = "" Then
   MsgBox ("Fail")
Else
   MsgBox ("Pass")
End If
 
Thanks Peter that worked a treat. I won't get phone calls now about messages poping up on the screen
 

Users who are viewing this thread

Back
Top Bottom