Seating priority dilemma

Started by jik_ff, January 15, 2018, 07:48:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jik_ff

 I'm not sure if this is a issue on the Visio side of things or from the data source, but thought I'd start here as Visio has the final output.

I have a database that manages staff seating and office layout.  This data is read by a Visio file.  My problem is that I have to allow for shared seating.  This translates to Conflicts on the Visio diagram as one 'seating cell' may have more than one name.  for now I handle that with an auto selection of the first name (alphabetically) through some VB code.  It was kind of a quick solution as I created this little beast.  Now that it is getting more use (across the country) other offices would like to be able to specify who is the Primary seat holder.

Here is the current conflict deflector:
Private Sub CheckConflicts()
    Dim aRS As Visio.DataRecordset
    Dim iCount As Integer
    Dim iShape As Integer
    Dim arrayShapes() As Visio.Shape
   
    Dim rowCount As Integer
    Dim cShape As Visio.Shape
   
    Dim allRowIDS() As Long
    Dim rowID As Long
    Dim firstRow As Long
   
   
    'get the recordset object - linked data
    iCount = Visio.ActiveDocument.DataRecordsets.Count
    Set aRS = Visio.ActiveDocument.DataRecordsets(iCount)
   
    'recordset was refreshed prior to this SUB, check for conflicts
    arrayShapes = aRS.GetAllRefreshConflicts
   
    If IsEmpty(arrayShapes) Then
        Debug.Print "***No Conflicts in Data Refresh***"
    Else
        'found conflicts....
        For iCount = LBound(arrayShapes) To UBound(arrayShapes)
            Set cShape = arrayShapes(iCount)
            allRowIDS = aRS.GetMatchingRowsForRefreshConflict(cShape)
           
            If IsEmpty(allRowIDS) Then
                Debug.Print "DATA row deleted for shape : " & cShape.Name
            Else
                For rowCount = LBound(allRowIDS) To UBound(allRowIDS)
                    rowID = allRowIDS(rowCount)
                   
                    Debug.Print "For Shape: ", cShape.Name, " RowID of row in conflict:", rowID
                    'look here:
                    'https://msdn.microsoft.com/en-us/library/office/ff765564(v=office.15).aspx
                    'to attempt to assign the first row to fix the conflict...
                Next rowCount
                'always re-link shape to first row of data when conflicted
                firstRow = allRowIDS(0)
                cShape.LinkToData aRS.ID, firstRow
            End If
           
        Next iCount
    End If
End Sub


hopefully that brief description is enough for a bit of guidance on how to tackle this.  My first thought is to have a 'flag' column in which you mark if a person is the primary.  Might be that I can fight through adjusting the above code to look at that value.  Then I'd have to do some clean up on the Access/SQL side of things.  But before I did that overhaul, was wondering if anyone had any ideas?

Thanks.