C
Ceebaby via AccessMonster.com
Hi Folks
Sorry for the double post, I should have posted this thread here instead of
the general forum.
I have a user selection form with multiple combo box fields which are to make
a selection to build criteria for a report.
I have just realised that some of the records in the underlying tables used
to create the lists for the combo boxes have apostraphes - eg St Jame's
Avenue. O'leary Close
I am having a real problem trying to build a WHERE clause for the field that
may contain the apostraphe.
I have tried multiple combinations of double quotes but cannot get it to work.
I can get it to work on the first WHERE clause but not on subsequent ones.
Here's my where clause so far
If Not IsNull(Me!ChWard) Then
strwhere = "WardName = """ & Me![ChWard] & """ And" ' Could have a
ward with an apostraphe
End If ' This where clause works and returns values with apostraphes for
the report
If Not IsNull(Me!ChArea) Then
strwhere = strwhere & " Area = '" & Me!ChArea & "' And" ' There are no
areas with apostraphes
End If
If Not IsNull(Me!ChCaseOfficer) Then
strwhere = strwhere & "CaseOfficer = """& Me!ChCaseOfficer & """" And"
'Officers names could have an apostraphe this clause does not work
End If
If Not IsNull(Me!ChRoad) Then
strwhere = strwhere & "Road = """ & Me![ChRoad] & """" And"
'Some roads have apostraphes but this clause does not work either
End If
If Not IsNull(Me!ChProp) Then
strwhere = strwhere & " [Property Type] = '" & Me!ChProp & "' And"
'Properties won't have apostraphes
End If
If Right(strwhere, 4) = " And" Then
strwhere = Trim(Left(strwhere, Len(strwhere) - 4))
Else
strwhere = Trim(strwhere)
End If
DoCmd.OpenReport RptName, acViewPreview, , strwhere
Any ideas how I can make these where clauses work. Your help as always is
much appreciated.
Cheers
Ceebaby
Sorry for the double post, I should have posted this thread here instead of
the general forum.
I have a user selection form with multiple combo box fields which are to make
a selection to build criteria for a report.
I have just realised that some of the records in the underlying tables used
to create the lists for the combo boxes have apostraphes - eg St Jame's
Avenue. O'leary Close
I am having a real problem trying to build a WHERE clause for the field that
may contain the apostraphe.
I have tried multiple combinations of double quotes but cannot get it to work.
I can get it to work on the first WHERE clause but not on subsequent ones.
Here's my where clause so far
If Not IsNull(Me!ChWard) Then
strwhere = "WardName = """ & Me![ChWard] & """ And" ' Could have a
ward with an apostraphe
End If ' This where clause works and returns values with apostraphes for
the report
If Not IsNull(Me!ChArea) Then
strwhere = strwhere & " Area = '" & Me!ChArea & "' And" ' There are no
areas with apostraphes
End If
If Not IsNull(Me!ChCaseOfficer) Then
strwhere = strwhere & "CaseOfficer = """& Me!ChCaseOfficer & """" And"
'Officers names could have an apostraphe this clause does not work
End If
If Not IsNull(Me!ChRoad) Then
strwhere = strwhere & "Road = """ & Me![ChRoad] & """" And"
'Some roads have apostraphes but this clause does not work either
End If
If Not IsNull(Me!ChProp) Then
strwhere = strwhere & " [Property Type] = '" & Me!ChProp & "' And"
'Properties won't have apostraphes
End If
If Right(strwhere, 4) = " And" Then
strwhere = Trim(Left(strwhere, Len(strwhere) - 4))
Else
strwhere = Trim(strwhere)
End If
DoCmd.OpenReport RptName, acViewPreview, , strwhere
Any ideas how I can make these where clauses work. Your help as always is
much appreciated.
Cheers
Ceebaby