janp
asked on
Open a recordset in VBA using SQL with LIKE
Hello,
This may have a very simple solution.
I'm trying to open a recordset using visual basic syntax (see code below). If I run the same SQL statement as a query (SELECT [tbl Segments].* FROM [tbl Segments] WHERE [tbl Segments].sSegment LIKE 'Step[_]*';), it runs just fine and records are returned. But when I use the same SQL syntax in a recordset.open statement, nothing is returned. I know it must be something with the LIKE statement because I can replace the LIKE statement with ='Step_01' and it runs fine.
Is there something about the LIKE statement when it is being used in SQL in visual basic code?
Thanks
This may have a very simple solution.
I'm trying to open a recordset using visual basic syntax (see code below). If I run the same SQL statement as a query (SELECT [tbl Segments].* FROM [tbl Segments] WHERE [tbl Segments].sSegment LIKE 'Step[_]*';), it runs just fine and records are returned. But when I use the same SQL syntax in a recordset.open statement, nothing is returned. I know it must be something with the LIKE statement because I can replace the LIKE statement with ='Step_01' and it runs fine.
Is there something about the LIKE statement when it is being used in SQL in visual basic code?
Thanks
sSQL = "SELECT [tbl Segments].* " & _
"FROM [tbl Segments] " & _
"WHERE [tbl Segments].sSegment LIKE 'Step[_]*';"
rs.Open sSQL, CurrentProject.Connection, adOpenStatic, adLockReadOnly, adCmdText
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER