|
-
Aug 31st, 2000, 07:57 AM
#1
Thread Starter
Member
recset.Filter = "TITLE = '" & strVar & "'"
if strVar has a ' or a " it bombs out. Is there a way around this, other than physicaly taking the 's and "s out of the string? (if I do that the filter won't filter properly!!)
-
Aug 31st, 2000, 08:38 AM
#2
Fanatic Member
Before setting your filter, put strVar through a procedure such as ...
Code:
Public Sub InsertSingleQuote(SourceString As String)
'***************************************************************************
'Purpose: Replaces single single quotes with double single quotes.
'Parameters: SourceString - String to be formatted.
'Returns: None.
'***************************************************************************
On Error GoTo ErrorHandler
SourceString = Replace(SourceString, "'", "''")
Procedure_Exit:
Exit Sub
ErrorHandler:
Select Case Err.Number
Case Else
GlobalErr Err.Number, Err.Description, "basUtilities - InsertSingleQuote"
Resume Procedure_Exit
Resume
End Select
End Sub
Hope this helps
VB6 sp5, SQL Server 2000, C#
There are no stupid questions. Only stupid people. 
-
Aug 31st, 2000, 10:10 AM
#3
New Member
You Should do this
rs.Filter = "Field = '" & Replace(strVar,"'","''") & "'"
This should work
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
|
Click Here to Expand Forum to Full Width
|