operator as a variable (syntax ?)

  • Thread starter Thread starter Mark Kubicki
  • Start date Start date
M

Mark Kubicki

i'm having syntax problems setting an operator as a variable... any
suggestions would be greatl;y appreciated

If strFileType = ... Then
strCriteria = "<> "
Else
strCriteria = "="
End If

' Loop through all tables in the database.
Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
If Left(tdf.Name, 3) & strCriteria & "tbe" Then
...


thanks in advance,
mark
 
well, the problem is you're passing a string value, so your expression comes
out as a string, as

"the value of Left(tdf.Name, 3)=tbe"

a string won't run by itself - it's just a string; but it might work in the
Eval() function, as

If strFileType = ... Then
strCriteria = " <> "
Else
strCriteria = " = "
End If
If Eval(Left(tdf.Name, 3) & strCriteria & "tbe")

i'm assuming that you're replacing the ... in the above code with an actual
string value. recommend you read up on the Eval() function in VBA Help. if
the Eval() function doesn't do it, you can always include the logic in your
loop, as

' Loop through all tables in the database.
Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
If strFileType = "something" Then
If Left(tdf.Name, 3) <> "tbe" Then
' do something
End If
Else
If Left(tdf.Name, 3) = "tbe" Then
' do something
End If
End If

hth
 
i'm having syntax problems setting an operator as a variable... any
suggestions would be greatl;y appreciated

If strFileType = ... Then
        strCriteria = "<> "
    Else
        strCriteria = "="
    End If

   ' Loop through all tables in the database.
   Set dbs = CurrentDb
   For Each tdf In dbs.TableDefs
       If Left(tdf.Name, 3) & strCriteria & "tbe" Then
   ...

do it the easy way...
If strFileType = ... Then
if left(tdf.name,3) ="tbe" then
'do one thing
else ' --- the only other alternative!
'do something else
end if
end if
 
thanks everybody..
-m.



i'm having syntax problems setting an operator as a variable... any
suggestions would be greatl;y appreciated

If strFileType = ... Then
strCriteria = "<> "
Else
strCriteria = "="
End If

' Loop through all tables in the database.
Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
If Left(tdf.Name, 3) & strCriteria & "tbe" Then
...

do it the easy way...
If strFileType = ... Then
if left(tdf.name,3) ="tbe" then
'do one thing
else ' --- the only other alternative!
'do something else
end if
end if
 
Back
Top