Dumferling
Member
- Local time
- Today, 14:24
- Joined
- Apr 28, 2020
- Messages
- 102
I am building a filter for a multi parameter query. Users select from the dropdowns and then the code assembles the criteria. I am not seeing the results that I expect. The code is a re-use from other forms where it has worked effectively. Of the three criteria, one assembles properly, one just doesn't work and the third breaks down the wording into separate words.
The first successful one looks like this:
If Not IsNull(Me.cboLegal) Then
If vblWhere = " WHERE " Then
vblWhere = vblWhere & BuildCriteria("tblAMMBusiness.LegalAdviser", dbText, cboLegal)
Else
vblWhere = vblWhere & " and " & BuildCriteria("tblAMMBusiness.LegalAdviser", dbText, cboLegal)
End If
End If
cboLegal looks like this:
(my name so not worried about personal information)
The second code looks like this:
If Not IsNull(Me.cboStatus) Then
If vblWhere = " WHERE " Then
vblWhere = vblWhere & BuildCriteria("tblRUpdates.BUUpdated", dbText, cboStatus)
Else
vblWhere = vblWhere & " and " & BuildCriteria("tblRUpdates.BUUpdated", dbText, cboStatus)
End If
End If
vboStatus looks like this:
The string simply does not assemble even though the lines are processed.
THe third code looks like this:
If Not IsNull(Me.cboBU) Then
If vblWhere = " WHERE " Then
vblWhere = vblWhere & BuildCriteria("tblRUpdates.BusinessUnit", dbText, cboBU)
Else
vblWhere = vblWhere & " and " & BuildCriteria("tblRUpdates.BusinessUnit", dbText, cboBU)
End If
End If
cboBU looks like this:
When the string assembles into the Where clause it looks like this:
" WHERE tblAMMBusiness.LegalAdviser="David Knight" and tblRUpdates.BusinessUnit="Client Solutions""
The second criteria is missing which suggests it is reading it as a Null. However, I have checked that the code actually executes - it just doesn't assemble the string.
From the third code if I change the criteria it looks like this:
On assembly it looks like this:
" WHERE tblAMMBusiness.LegalAdviser="David Knight" and tblRUpdates.BusinessUnit="Service" And tblRUpdates.BusinessUnit="Operations""
The second criteria is still missing and it has now split the phrase into 2 parts. I assume that it is somehow reading the "and" and creating two terms.
I am mystified by the lack of assembly of the second criteria and cannot find any tips on how to hand the break up in the third code block if I have an "and" in the criteria. Any advice would be most welcome!
The first successful one looks like this:
If Not IsNull(Me.cboLegal) Then
If vblWhere = " WHERE " Then
vblWhere = vblWhere & BuildCriteria("tblAMMBusiness.LegalAdviser", dbText, cboLegal)
Else
vblWhere = vblWhere & " and " & BuildCriteria("tblAMMBusiness.LegalAdviser", dbText, cboLegal)
End If
End If
cboLegal looks like this:
The second code looks like this:
If Not IsNull(Me.cboStatus) Then
If vblWhere = " WHERE " Then
vblWhere = vblWhere & BuildCriteria("tblRUpdates.BUUpdated", dbText, cboStatus)
Else
vblWhere = vblWhere & " and " & BuildCriteria("tblRUpdates.BUUpdated", dbText, cboStatus)
End If
End If
vboStatus looks like this:
The string simply does not assemble even though the lines are processed.
THe third code looks like this:
If Not IsNull(Me.cboBU) Then
If vblWhere = " WHERE " Then
vblWhere = vblWhere & BuildCriteria("tblRUpdates.BusinessUnit", dbText, cboBU)
Else
vblWhere = vblWhere & " and " & BuildCriteria("tblRUpdates.BusinessUnit", dbText, cboBU)
End If
End If
cboBU looks like this:
When the string assembles into the Where clause it looks like this:
" WHERE tblAMMBusiness.LegalAdviser="David Knight" and tblRUpdates.BusinessUnit="Client Solutions""
The second criteria is missing which suggests it is reading it as a Null. However, I have checked that the code actually executes - it just doesn't assemble the string.
From the third code if I change the criteria it looks like this:
On assembly it looks like this:
" WHERE tblAMMBusiness.LegalAdviser="David Knight" and tblRUpdates.BusinessUnit="Service" And tblRUpdates.BusinessUnit="Operations""
The second criteria is still missing and it has now split the phrase into 2 parts. I assume that it is somehow reading the "and" and creating two terms.
I am mystified by the lack of assembly of the second criteria and cannot find any tips on how to hand the break up in the third code block if I have an "and" in the criteria. Any advice would be most welcome!