I have a database with a table that is a child to many other tables. I am using this child table as a datasource for a datagridview. I am using comboboxes to display specific fields in any parent tables, instead of the user seeing the foreign key. Everything is fine.
However, I would like to filter the BindingSource based on text matches between any of the fields in the child table and the corresponding fields of the parent tables.
I have spent the last 6 or 8 hours scouring the internet for answers and trying various ideas, but to no avail! I'm extremely frustrated.
For example, according to MS (see here), the following code should filter my datatable when text is typed into a textbox named txtRefFireDFilter:
Now this assumes that there is a parent-child reference named "RefFireD2Manf". I am certain of this reference, as I see it both in the design-time screen and in the .designer code. Unfortunately, the following error is thrown:Code:Private Sub txtRefFireDFilter_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtRefFireDFilter.TextChanged Dim tb As TextBox = CType(sender, TextBox) If tb.TextLength = 0 Then bsRefFireD.RemoveFilter() Else bsRefFireD.Filter = String.Format("Parent(RefFireD2Manf).Name LIKE '*{0}*'", tb.Text) End If End Sub
Also, placing the reference name in single quotes and/or square brackets will only break the parser:Code:Cannot find the parent relation 'RefFireD2Manf'.
As far as I can tell, this is a bug in VS. The linked article mentions a work-around, by I'm too taxed right now to try and implement it, as a first pass read was over my head.Code:Syntax error in Lookup expression: Expecting keyword 'Parent' followed by a single column argument with possible relation qualifier: Parent[(<relation_name>)].<column_name>.




Reply With Quote