georgedwilkinson
AWF VIP
- Local time
- Today, 12:36
- Joined
- Mar 4, 2008
- Messages
- 3,856
I am trying to filter an ADO recordset and I keep getting an error when I use a filter criteria with a space (" ") in it. The indicated line below errors out with:
The immediate window shows:
Before the failure, the filter had successfully been set to everything before the space (i.e. "w", "wi", "wid", "wido", "widow", "widow'", and "widow's"). Additionally, any time I put a space in the control, I get this error. There are matching records in the result set (i.e. "widow's creek").
FYI, the purpose of the code is to filter a combo box with an incredibly large (and growing) result set.
This code was originally from http://www.databasedevelopment.co.uk/examples.htm, but has been highly modified to fit my needs and programming standards. It works perfectly except the space problem in the filter criteria.
Additional information--the BE is on SQL Server 2000, the FE is Access 2002, the query takes data from a linked SQL Server view.
I'm pretty much at my wits end on this and am probably no longer thinking straight. Any help is appreciated.
3001 Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
The immediate window shows:
LongSiteName like "widow's %"
Before the failure, the filter had successfully been set to everything before the space (i.e. "w", "wi", "wid", "wido", "widow", "widow'", and "widow's"). Additionally, any time I put a space in the control, I get this error. There are matching records in the result set (i.e. "widow's creek").
FYI, the purpose of the code is to filter a combo box with an incredibly large (and growing) result set.
This code was originally from http://www.databasedevelopment.co.uk/examples.htm, but has been highly modified to fit my needs and programming standards. It works perfectly except the space problem in the filter criteria.
Code:
If g_rstSiteList Is Nothing Then
Set g_rstSiteList = New ADODB.Recordset
g_rstSiteList.CursorLocation = adUseClient
l_strSQL = "SELECT qryAESDDL.SiteID, " _
& "qryAESDDL.LongSiteName, qryAESDDL.ShortSiteName, " _
& "qryAESDDL.SiteCode, qryAESDDL.City, qryAESDDL.State, " _
& "qryAESDDL.Country " _
& "FROM qryAESDDL ORDER BY LongSiteName;"
'Debug.Print "SQL: " & vbCrLf & l_strSQL
g_rstSiteList.Open l_strSQL, CurrentProject.Connection, adOpenKeyset, adLockReadOnly
End If
'Set the local filter for the recordset.
l_strFilter = "LongSiteName like " & l_strDoubleQuote & MyText & "%" & l_strDoubleQuote
Debug.Print l_strFilter
[COLOR=red][B]g_rstSiteList.Filter = l_strFilter[/B][/COLOR]
Additional information--the BE is on SQL Server 2000, the FE is Access 2002, the query takes data from a linked SQL Server view.
I'm pretty much at my wits end on this and am probably no longer thinking straight. Any help is appreciated.