I am trying to extract result from an existing query but with or without where clause.
The query is if myDepartment is * then display everything else just display certain department name.
The codes below seems to work BUT only where myDepartment contain only one word i.e. "Sales" but when it contained a space i.e. "Human Resources" the query is displaying everything. "Sales" just lists Sales only
WHRstr = "WHERE [DEPARTMENT] >= '" & myDepartment & "'"
QRYstr = "[Proposals - " & dbChoice(i) & "]"
If myDepartment = "*" Then
SQLstr = "SELECT * FROM " & QRYstr
Else
SQLstr = "SELECT * FROM " & QRYstr & WHRstr
End If
Set TBLobj = db.CreateQueryDef("tempQ", SQLstr)
What have I done wrong?
The query is if myDepartment is * then display everything else just display certain department name.
The codes below seems to work BUT only where myDepartment contain only one word i.e. "Sales" but when it contained a space i.e. "Human Resources" the query is displaying everything. "Sales" just lists Sales only
WHRstr = "WHERE [DEPARTMENT] >= '" & myDepartment & "'"
QRYstr = "[Proposals - " & dbChoice(i) & "]"
If myDepartment = "*" Then
SQLstr = "SELECT * FROM " & QRYstr
Else
SQLstr = "SELECT * FROM " & QRYstr & WHRstr
End If
Set TBLobj = db.CreateQueryDef("tempQ", SQLstr)
What have I done wrong?