Trying to construct an sql string that will be used in VBA to select records from a table. I cannot figure how to use the wildcard character. Compiler does not like "*" and converts to " * ". Have also tried "'*" (double, single, asterisk, double), but can't get around compiler treating ' as comment start.
Can someone please correct the syntax below for a multi-parameter SQL string with 'Like' command?
Thanks.
Can someone please correct the syntax below for a multi-parameter SQL string with 'Like' command?
Code:
strSql = "SELECT [t1].f1, [t1].f2, [t1].f3, [t1].f4, [t1].f5, [t1].f6, [t1].f7 " _
& "FROM [t1] " _
& "WHERE ((([t1].f1) Like " * " & [forms]![SearchF]![f1] & " * ") " _
& "AND (([t1].f2) Like " * " & [forms]![SearchF]![f2] & " * ") " _
& "AND (([t1].f3) Like " * " & [forms]![SearchF]![f3] & " * ") " _
& "AND (([t1].f4) Like " * " & [forms]![SearchF]![f4] & " * ") " _
& "AND (([t1].f5) Like " * " & [forms]![SearchF]![f5] & " * ") " _
& "AND (([t1].f6) Like " * " & [forms]![SearchF]![f6] & " * "));"