-
Wildcard in SQL
Hi folks
Not been on for a while
How do I use a wildcard value in an SQL
heres my SQL
[VBA]Private Sub BuildList(cGroup As String, cType As String, active As Boolean)
Dim qry As String
Dim idx As Long, icon As Long
qry = "SELECT TblComponentDetail.ComponentID, TblComponentDetail.ComponentGroupID, " & _
"TblComponentDetail.ComponentTypeID, TblComponentDetail.ActiveToDate, " & _
"TblComponentDetail.Description, TblComponentDetail.ActiveFlag, TblComponentDetail.Make, " & _
"TblComponentDetail.Model " & _
"FROM TblComponentDetail " & _
"WHERE (((TblComponentDetail.ComponentGroupID)='" & cGroup & "') " & _
"AND ((TblComponentDetail.ComponentTypeID)='" & cType & "') " & _
"AND ((TblComponentDetail.ActiveToDate)>Now()) " & _
"AND ((TblComponentDetail.ActiveFlag)=True));"[/VBA]
If I dont know cType when I run the SQL what value should I use to represent cType when calling the routine e.g.
[VBA]Call BuildList(cGroup, "*", True)[/VBA]
I have tried
like"*" but that comes up with a mismatch error
I have tried just * and _
but no joy.
-
Probably not the best solution but what about an if clause to check if ctype is known. If it's blank, don't include this field in your query and perform the query without this field.
Charlize
-
Try % instead of * and _ instead of ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules