Here's some code...you may need to tweek it to match your table name. (mine is: TBL = "tDevices" )
in vbe run : FineActiveDevice
it will scan the table plotting the path to the active device.
Code:
Private Const kTBL = "tDevices"
Public Sub FineActiveDevice()
Dim rst
Dim vID, vNext, vPrev, vName
Dim vStatus
Dim sSql As String
sSql = "select * from " & kTBL & " ORDER BY [ID]"
Set rst = CurrentDb.OpenRecordset(kTBL)
With rst
While Not .EOF
vID = .Fields("ID").Value & ""
vNext = .Fields("Device_ID").Value & ""
vName = .Fields("Device").Value & ""
vStatus = Left(.Fields("Sort").Value & "", 1)
If vStatus <> "A" Then
FindStatus vNext
Else
PostTrail vID, vName, vStatus, "--end"
End If
.MoveNext
Wend
End With
Set rst = Nothing
End Sub
Public Sub FindStatus(ByVal pvID)
Dim rst
Dim vID, vNext, vPrev
Dim vStatus
Dim sSql As String
On Error GoTo endIt
sSql = "select * from " & kTBL & " where [ID]='" & pvID & "'"
Set rst = CurrentDb.OpenRecordset(sSql)
With rst
vStatus = Left(.Fields("Sort").Value & "", 1)
vName = .Fields("Device").Value & ""
vNext = .Fields("Device_ID").Value & ""
PostTrail pvID, vName, vStatus, vNext
If vStatus = "A" Then
PostTrail "", vName, vStatus, "--end"
Else
FindStatus vNext
End If
End With
endIt:
Set rst = Nothing
End Sub
Public Sub PostTrail(pvID, pvName, pvStatus, pvNext)
'write to table
sSql = "insert into table ([ID],["
'or
'write to debug window
Debug.Print pvID, pvName, pvStatus, pvNext
End Sub