Thanks, I will consider your solution further. I noticed I made an error in my code example, which was a simplified version of my actual code.
I wrote
Code:
If (CantFindFile(sName)) Then
bFileMissing = False
Else
bFileMissing = True
End If
which should have been
If (CantFindFile(sName)) Then
bFileMissing = True
Else
bFileMissing = False
End If
The actual code I’m trying to reduce is this (Me is an Access form):
Code:
'Now look for a folder containing the ID.
sSearchPath = sCategoryPath & "\*" & Me.txtID & "*"
If Dir(sSearchPath, vbDirectory) = "" Then
' We didn't find it. If both Current and MP were checked, then look for it in the other directory.
' Note that another routine will inform the user about this situation.
If bErrorCurrentAndMPBothChecked Then
If sCategoryPath = sCategoryPath = m_RootFolderPath & "\" & "Current" Then
sCategoryPath = m_RootFolderPath & "\" & "MeaningfulPast"
sCategory = "MeaningfulPast"
Else
sCategoryPath = sCategoryPath = m_RootFolderPath & "\" & "Current"
sCategory = "Current"
End If
' Now that we switched, try again...
sSearchPath = sCategoryPath & "\*" & Me.txtID & "*"
If Dir(sSearchPath, vbDirectory) = "" Then
bFolderNotFound = True
Else
' We found it in the other folder.
bFolderNotFound = False
sProfileFolderName = Dir(sSearchPath, vbDirectory)
End If
Else
bFolderNotFound = True
End If
Else
bFolderNotFound = False
sProfileFolderName = Dir(sSearchPath, vbDirectory)
End If