Or Operator giving problem, in VBA ACCESS

antonio.manoj.derose

Registered User.
Local time
Today, 20:42
Joined
Jul 4, 2013
Messages
62
Hi Folks,

Please be good enough to help me in the below code, as I am getting to go into the MsgBox, as it should not, after if it should goto End If.

If Mid(fileName, InStrRev(fileName, "\") + 1, 5) = "Fixed" Or Mid(fileName, InStrRev(fileName, "\") + 1, 6) <> "Mobile" Then
MsgBox "Invalid filename to start with, Files to be started with Fixed or Mobile", vbCritical, "Invalid File Name"
Exit Function
End If

Thanks,

Antonio
 
Please post the entire code.

Dale
 
Try

If Not (Mid(fileName, InStrRev(fileName, "\") + 1, 5) = "Fixed" Or Mid(fileName, InStrRev(fileName, "\") + 1, 6) = "Mobile") Then
 
I'd change the = "Fixed" to <> "Fixed" as you have = where it should be <> from what I see there.
 
I'd change the = "Fixed" to <> "Fixed" as you have = where it should be <> from what I see there.

You can do that, but "Or" would have to be changed to "And".
 
You can do that, but "Or" would have to be changed to "And".
True, but that form would be more logical to me anyway. But whatever works should be sufficient.
 

Users who are viewing this thread

Back
Top Bottom