Dim pDoc As IMxDocument Dim pStandaloneTableColl As IStandaloneTableCollection Dim pStandaloneTable As IStandaloneTable Dim pSelectionSet As ISelectionSet Dim pTableSelection As ITableSelection 'Get the table collection from the map Set pDoc = ThisDocument Set pStandaloneTableColl = pDoc.FocusMap 'Get the first table Set pStandaloneTable = pStandaloneTableColl.StandaloneTable(0) 'Select rows based on a query filter Dim pQf As IQueryFilter Set pQf = New QueryFilter pQf.WhereClause = "UNIQUE_ID1 = 335" Set pSelectionSet = pStandaloneTable.Table.Select(pQf, esriSelectionTypeIDSet, esriSelectionOptionNormal, Nothing) 'Apply the selection Set pTableSelection = pStandaloneTable Set pTableSelection.SelectionSet = pSelectionSet
dim pCur as icursor dim pRow as iRow pSelectionSet.search nothing,false, pCur set pRow = pcur.nextrow do until prow is nothing frm_Images.listbox1.additem(pRow.value(2)) set prow = pcur.nextrow loop
Private Sub CommandButton1_Click()
' Get the UNIQUEID of the feature, this will be used later to the related records
Dim varID As String
varID = frm_Images.TextBox8.Text
Dim pMxDoc As IMxDocument
Set pMxDoc = Application.Document
Dim pMap As IMap
Set pMap = pMxDoc.FocusMap
Dim pTables As IStandaloneTableCollection
Set pTables = pMap
Dim strTableName1 As String
strTableName1 = "oufalls_historical"
Dim i As Integer
For i = 0 To pTables.StandaloneTableCount - 1
If pTables.StandaloneTable(i).Name = strTableName1 Then
Dim pTable As IStandaloneTable
Set pTable = pTables.StandaloneTable(i)
' Hook the Table Class
Dim tClass As ITable
Set tClass = pTable.Table
' Hook the Table Cursor
Dim tCursor As ICursor
Set tCursor = tClass.Insert(True)
' Hook the Fields
Dim tFields As IFields
Set tFields = tClass.Fields
Else
End If
Next
Dim pTableSort As ITableSort
Dim pTrackCancel As ITrackCancel
'Sort the table based on the field
Set pTableSort = New TableSort
Set pTrackCancel = New CancelTracker
Set pTableSort.Table = pTable
pTableSort.Fields = "INSPECT_YR"
pTableSort.Ascending("INSPECT_YR") = False
pTableSort.Sort pTrackCancel
Dim AddressCollection As New Collection
Dim pSortedCursor As ICursor
Dim pRowBuff As IRowBuffer
'Set cursor to increment through sorted table, one row at a time
Set pSortedCursor = pTableSort.Rows
Set pRowBuff = pSortedCursor.NextRow
'Loop through table and create a collection of values
Do While Not pRowBuff Is Nothing
If IsNull(pRowBuff.Value(7)) Then
Set pRowBuff = pSortedCursor.NextRow
Else
Dim varValue As String
varValue = pRowBuff.Value(23)
'MsgBox varValue
If varValue = varID Then
'AddressCollection.Add pRowBuff.Value(7)
frm_Outfalls_Images.ListBox2.AddItem (pRowBuff.Value(7))
Else
End If
Set pRowBuff = pSortedCursor.NextRow
End If
Loop
End Sub
'Loop through table and create a collection of values Do While Not pRowBuff Is Nothing If IsNull(pRowBuff.Value(7)) Then Set pRowBuff = pSortedCursor.NextRow Else Dim varValue As String varValue = pRowBuff.Value(7) 'MsgBox varValue If varValue = varCollectedDate Then ' populate textboxes with attributes of selected related record. varUTIL_ID = pRowBuff.Value(1) varGRATE_ = pRowBuff.Value(2) varCONDTN = pRowBuff.Value(3) varOBSTRUCTN = pRowBuff.Value(4) varOF_RECWTR = pRowBuff.Value(5) varCOMMENTS = pRowBuff.Value(6) frm_Images.TextBox17.Value = varUTIL_ID frm_Images.TextBox18.Value = varGRATE_ frm_Images.TextBox19.Value = varCONDTN frm_Images.TextBox20.Value = varOBSTRUCTN frm_Images.TextBox21.Value = varOF_RECWTR frm_Images.TextBox22.Value = varCOMMENTS Else End If Set pRowBuff = pSortedCursor.NextRow End If Loop