I'm trying to fill a recordset based on a sql statement that I generate through code. Part of the sql statement is a LIKE condition. Whenever I run the sql statement with the LIKE statement included, the recordset never opens any records (recordcount = 0, BOF and EOF are true). If I exclude the LIKE statement, the recordset populates with records.
I know the sql statement is right because it runs when I paste it into the SQL view of an Access query, which returns 5 records. Here is the sql statement:
sSql = "SELECT SWOID, "
sSql = sSql & "[tblSWO].TeamName, "
sSql = sSql & "[tblSWO].Difficulty, "
sSql = sSql & "[tblSWO].Contractor, "
sSql = sSql & "[tblSWO].[Machine#], "
sSql = sSql & "[tblSWO].Type, "
sSql = sSql & "[tblSWO].Description, "
sSql = sSql & "[tblSWO].Estimated_start_date, "
sSql = sSql & "[tblSWO].Estimated_finish_date, "
sSql = sSql & "[tblSWO].Actual_start_date, "
sSql = sSql & "[tblSWO].Actual_finish_date, "
sSql = sSql & "[tblSWO].Cost, "
sSql = sSql & "[tblSWO].Approval, "
sSql = sSql & "[tblSWO].[Completed?], "
sSql = sSql & "[tblSWO].[Estimated Man Hours], "
sSql = sSql & "[tblSWO].Priority, "
sSql = sSql & "[qrypastSWO].CountOfSWOID "
sSql = sSql & "FROM tblSWO, qrypastSWO "
sSql = sSql & "WHERE [Completed?] = 'Closed' "
sSql = sSql & "AND tblSWO.description LIKE '*" & txtdescription.Value & "*' "
sSql = sSql & "ORDER BY tblSWO.Actual_finish_date"
I'd appreciate any thoughts. Thanks!
jender624
I know the sql statement is right because it runs when I paste it into the SQL view of an Access query, which returns 5 records. Here is the sql statement:
sSql = "SELECT SWOID, "
sSql = sSql & "[tblSWO].TeamName, "
sSql = sSql & "[tblSWO].Difficulty, "
sSql = sSql & "[tblSWO].Contractor, "
sSql = sSql & "[tblSWO].[Machine#], "
sSql = sSql & "[tblSWO].Type, "
sSql = sSql & "[tblSWO].Description, "
sSql = sSql & "[tblSWO].Estimated_start_date, "
sSql = sSql & "[tblSWO].Estimated_finish_date, "
sSql = sSql & "[tblSWO].Actual_start_date, "
sSql = sSql & "[tblSWO].Actual_finish_date, "
sSql = sSql & "[tblSWO].Cost, "
sSql = sSql & "[tblSWO].Approval, "
sSql = sSql & "[tblSWO].[Completed?], "
sSql = sSql & "[tblSWO].[Estimated Man Hours], "
sSql = sSql & "[tblSWO].Priority, "
sSql = sSql & "[qrypastSWO].CountOfSWOID "
sSql = sSql & "FROM tblSWO, qrypastSWO "
sSql = sSql & "WHERE [Completed?] = 'Closed' "
sSql = sSql & "AND tblSWO.description LIKE '*" & txtdescription.Value & "*' "
sSql = sSql & "ORDER BY tblSWO.Actual_finish_date"
I'd appreciate any thoughts. Thanks!
jender624