operator as a variable

  • 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
 
hi Mark,

Mark said:
i'm having syntax problems setting an operator as a variable... any
suggestions would be greatl;y appreciated
This only possible when using the Eval() function.
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
...
I don't see the sense in this construct. The better approach could be to
split the functionality into more parts:

Private Sub YourEntryPoint(strFileType As String)

If strFileType = .. Then
NotEqualProc
Else
EqualProc
End If

End Sub

Private Sub EqualProc()

Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
If Left(tdf.Name, 3) & "=tbe" Then
WorkProc(tdf)
End If
Next tdf

End Sub

Private Sub NotEqualProc()

Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
If Left(tdf.Name, 3) & "<>tbe" Then
WorkProc(tdf)
End If
Next tdf

End Sub

Private Sub WorkProc(tdf As DAO.TableDef)
End Sub



mfG
--> stefan <--
 
Back
Top