C
Ceebaby via AccessMonster.com
Hi Folks
I have a project form where I have a button that when clicked it it opens
another form of property addresses filtered to selections made in 3 fields
called projectArea1, projectArea2 and projectArea3 which are a selection of
different roads. Each project could have 1 road involved or up to 3 roads.
The form is based on a query and I am trying to get the criteria field of the
Road field on the query to accept the strwhere clause below.
I have been trying to use the strwhere and LIKE operator to filter the form
to the roads inputted on the projectArea text fields.
Dim CaseFrm As String
Dim strWhere As String
CaseFrm = "ProjectCaseMgtF"
If Not IsNull(Me!ProjectArea1) Then
strWhere = "[Road]like Me!ProjectArea1" & " Or """
End If
If Not IsNull(Me!ProjectArea2) Then
strWhere = strWhere & "[Road]like Me!ProjectArea2" & " Or """
End If
If Not IsNull(Me!ProjectArea3) Then
strWhere = strWhere & "[Road] like Me!ProjectArea3" & " Or """
End If
If Right(strWhere, 4) = " Or" Then
strWhere = Trim(Left(strWhere, Len(strWhere) - 4))
Else
strWhere = Trim(strWhere)
End If
DoCmd.OpenForm CaseFrm, acNormal, , strWhere
I get either a syntax error message, or the form doesnt filter to the roads
indicated in each of the projectArea text fields.
I have seen examples of mulitple criteria on different text fields, but not
on 1 field.
Basically I am trying to achieve the following eg "Bowles Road or Hendon Road
or Chaplin avenue" which would be in the criteria field of the query if I
made it a static query.Is this possible? can it not be achieved from my code
above.
Any help would be appreciated.
--
Ceebaby
Trying to be great at Access
Message posted via AccessMonster.com
I have a project form where I have a button that when clicked it it opens
another form of property addresses filtered to selections made in 3 fields
called projectArea1, projectArea2 and projectArea3 which are a selection of
different roads. Each project could have 1 road involved or up to 3 roads.
The form is based on a query and I am trying to get the criteria field of the
Road field on the query to accept the strwhere clause below.
I have been trying to use the strwhere and LIKE operator to filter the form
to the roads inputted on the projectArea text fields.
Dim CaseFrm As String
Dim strWhere As String
CaseFrm = "ProjectCaseMgtF"
If Not IsNull(Me!ProjectArea1) Then
strWhere = "[Road]like Me!ProjectArea1" & " Or """
End If
If Not IsNull(Me!ProjectArea2) Then
strWhere = strWhere & "[Road]like Me!ProjectArea2" & " Or """
End If
If Not IsNull(Me!ProjectArea3) Then
strWhere = strWhere & "[Road] like Me!ProjectArea3" & " Or """
End If
If Right(strWhere, 4) = " Or" Then
strWhere = Trim(Left(strWhere, Len(strWhere) - 4))
Else
strWhere = Trim(strWhere)
End If
DoCmd.OpenForm CaseFrm, acNormal, , strWhere
I get either a syntax error message, or the form doesnt filter to the roads
indicated in each of the projectArea text fields.
I have seen examples of mulitple criteria on different text fields, but not
on 1 field.
Basically I am trying to achieve the following eg "Bowles Road or Hendon Road
or Chaplin avenue" which would be in the criteria field of the query if I
made it a static query.Is this possible? can it not be achieved from my code
above.
Any help would be appreciated.
--
Ceebaby
Trying to be great at Access
Message posted via AccessMonster.com