I'm sorry, I forgot it is the name of the control as a string value you pass
to it.
strWhere = BuildWhereCondition("txtfilterSA")
(just seeing if your paying attention and helping you with your debugging
skills
:
Alright...thats where it is...the highlighted line wiht Me.txtfilterSA
when i place hte cursor over that part says
Me.txtfilterSA=Null....hence the error...it seems that when i select
things in the txtfilterSA field they are not registering therefore
sending Null?
Klatuu wrote:
The function should be in the form module general section. That is at the
top of the module right after the Option statements, but before an form or
control related code.
:
I put the codes in, and adapted hte BuildWhereCondition codes so that
the Me.ListBox1 matches the Me.ListBox1 in this code...it asks to debug
and highlights this line...
strWhere = BuildWhereCondition(Me.txtfilterSA)
I just placed the BuildWhereCondition codes in vba.....is there a more
specific place i should attach this?
Klatuu wrote:
What you need to do to get list box 2 row source set up is to call the
function I posted earlier that will create the Where Clause based on the
selections made in list box 1. Then you use that to create the row source
for list box 2. Try this. Since I can't test it from here, it may not be
100% accurate, but test it. If you get any errors and can't figure them out,
post back with the error number and the line it occured on and I will help
you through it.
Private Sub txtfilterSA_Click()
Dim strSQL as String
Dim strWhere as String
strSQL = "SELECT DISTINCTROW [bfr data].ccn FROM [bfr data]"
strWhere = BuildWhereCondition(Me.ListBox1)
If Len(strWhere) > 0 Then
strWhere = " WHERE " & strWhere
End If
strSQL = strSQL & strWhere
Me.ListBox2.RowSource = strSQL
End Sub
:
Ok, my second list box used to have a record source of....
SELECT DISTINCTROW [bfr data].ccn FROM [bfr data] WHERE ((([bfr
data].sa) Like forms![search criteria test]!txtfiltersa));
Which workes with a single select list box.
and now there is an after update event in the first (multi select)list
box of...(i tried this in onclick for txtfilterCCN list box too)
Private Sub txtfilterSA_Click()
With Me.txtfilterCCN
strSQL = "SELECT DISTINCTROW [bfr data].ccn FROM [bfr data] "
strWhere = "WHERE(([bfr data].SA) Like Forms![search criteria
for Report Preview]![txtfilterSA])"
strSQL = strSQL & strWhere
If Len(strWhere) > 0 Then
strWhere = "WHERE " & strWhere
End If
If .RowSource = "" Then
.RowSource = "SELECT DISTINCT CCN " & _
"FROM [bfr data].CCN " & _
strWhere & _
"ORDER BY [bfr data].CCN;"
End If
End With
DoCmd.Hourglass False
End Sub
except nothing happens....
We want specific CCNs to be displayed based on SA's just like in a
single select list box.
Klatuu wrote:
If the Where condtion we fixed is to filter the first list box, what we want
to do is filter based on what is selected in the first list box and any other
filtering that is necessary. Post back with what the filtering rules are for
the second list box and we will go from there.