operator as a variable

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
 
S

Stefan Hoffmann

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 <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top