Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter a Parent table from Child criteria

Status
Not open for further replies.

mal54

Programmer
Mar 11, 2002
13
AU
I need to filter a parent table from child criteria. but the function only supports aggregate expressions i.e. sum(field).

My solution is a database for company representatives each rep has a territory and I just want to be able to find the reps that operate in a particular territory. The tblInstructor is the parent and the tblTerritory is the child the relationship is tblInstructortblteritory

this is my code can you give me a work around to help.
Regards Mal


Private Sub FilterInstructorTerritory()

Dim strCriteria As String = ""

Dim cmInstructorCityID As CurrencyManager = CType(Me.BindingContext(DsInstructor1, "tblInstructor"), CurrencyManager)

Dim dvInstructorSearchByCityID As DataView = CType(cmInstructorCityID.List, DataView)

If Not (Me.cboFilterCity.SelectedValue = Nothing) Then

If strCriteria <> "" Then strCriteria = strCriteria & " AND "

strCriteria = strCriteria & "Min(Child(tblInstructortblTerritory).CityID) = " & cboFilterCity.SelectedValue & ""

End If

dvInstructorSearchByCityID.RowFilter = strCriteria

If dvInstructorSearchByCityID.Count > 0 Then

Me.lblCountFilterInstr.Text = "Filtered"

Else

'Dim Found As Boolean = False

'Dim MyCollection As New Collection

'For Each MyObject As Object In MyCollection ' Iterate through elements.

'If CStr(MyObject.Text) = "Hello" Then ' If Text equals "Hello"

'Found = True ' Set Found to True.

'Exit For ' Exit loop.

'End If

' Next

dvInstructorSearchByCityID.RowFilter = "FinishDate Is Null"

MsgBox("No service in location.", , "")

End If

Me.objdsInstructor_PositionChanged()

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top