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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listview shows wrong data

Status
Not open for further replies.

jadams0173

Technical User
Feb 18, 2005
1,210
I have an SSTAB control which has a listview control array on the tabs. When I first load each listview control array on the tabs everything is fine. I have a refresh button in the tool bar that calls the FORM_LOAD event again.

What's happening is that after running the form load event again, 2 of my tabs (and it's random as to which two) have the same data on them. Or at least that what it appears to be. If I go to the immeadiate window and print the text of one of the column in the grid the correct data is there, I just don't see it on the screen.

It's almost like the I change tabs but the listview array doesn't follow the tabs of the SSTAB control. I've deleted the listview array and added back to the tab control but that didn't work.

Any ideas? Here is the code from my form_load

Code:
Private Sub Form_Load()
Dim intLoop     As Integer
Dim rs          As ADODB.Recordset
Dim iLineIdx    As MyLines

'initialize
IsFromHold = False

Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2

lblTitle.ForeColor = &H663300

Set rs = New ADODB.Recordset

rs.Open "Select * from Scheduler_Form where UserName = 'JA'", clOpenConn.clOpenConnSQL, adOpenStatic, adLockReadOnly, adCmdText
For intLoop = ListView1.LBound To ListView1.UBound
    With ListView1(intLoop)
        ListView1(intLoop).ListItems.Clear
        .Top = 960
        .Width = 12535
        .Height = 4335
        .Left = 240
        .LabelEdit = lvwManual
        .Appearance = 0
        .OLEDragMode = ccOLEDragAutomatic
        .OLEDropMode = ccOLEDropManual
        .ColumnHeaders.Add , , "Status", 700
        .ColumnHeaders.Add , , "MO Number", 1500
        .ColumnHeaders.Add , , "H Start Date", 900
        .ColumnHeaders.Add , , "Schedule Date", 1200
        .ColumnHeaders.Add , , "Item", 1500
        .ColumnHeaders.Add , , "QTY", 800
        .ColumnHeaders.Add , , "Side", 500
        .ColumnHeaders.Add , , "Pass", 500
        .ColumnHeaders.Add , , "Process Def", 1000
        .ColumnHeaders.Add , , "AOI", 1500
        .ColumnHeaders.Add , , "Feeders", 600
        .ColumnHeaders.Add , , "MO Picks", 600
        .ColumnHeaders.Add , , "Other Side", 500
        .ColumnHeaders.Add , , "HRS", 750
        .ColumnHeaders.Add , , "Action", 700
        .View = lvwReport
        .GridLines = True
'            .Checkboxes = True
        .FullRowSelect = True
'            .SmallIcons = ImageList1
    End With
Next

For intLoop = 1 To rs.RecordCount
    Select Case Trim(rs.Fields("PrimLine"))
        Case "B02"
            iLineIdx = LineB02
        Case "B03"
            iLineIdx = LineB03
        Case "B04"
            iLineIdx = LineB04
        Case "B05"
            iLineIdx = LineB05
        Case "B06"
            iLineIdx = LineB06
        Case "B07"
            iLineIdx = LineB07
        Case "B08"
            iLineIdx = LineB08
        Case "N-A"
            Select Case Trim(rs.Fields("MOTYPE"))
                Case "AI"
                    iLineIdx = AI
                Case "PTH"
                    iLineIdx = PTH
                Case "HLA"
                    iLineIdx = HLA
                Case Else
                    iLineIdx = LineHold
            End Select
            
        Case Else
            iLineIdx = LineHold
     End Select
     
     With ListView1(iLineIdx).ListItems.Add(, vbNullString, "")
        .ListSubItems.Add , "i" & Trim(rs.Fields("MO_number")), Trim(rs.Fields("MO_number"))
        .ListSubItems.Add , "i" & intLoop, Trim(rs.Fields("START_DATE"))
        .ListSubItems.Add , "i" & rs.Fields("SCHED_DATE"), Trim(rs.Fields("SCHED_DATE"))
        .ListSubItems.Add , "i" & Trim(rs.Fields("ITEM")), Trim(rs.Fields("ITEM"))
        .ListSubItems.Add , , Trim(rs.Fields("ORDER_QTY"))
        .ListSubItems.Add , , Trim(rs.Fields("TB"))
        .ListSubItems.Add , , Trim(rs.Fields("Pass"))
        .ListSubItems.Add , , Trim(rs.Fields("Process_def"))
        .ListSubItems.Add , , Trim(rs.Fields("AOI"))
        .ListSubItems.Add , , Trim(rs.Fields("FEEDERS"))
        .ListSubItems.Add , , Trim(rs.Fields("WH_PICKS"))
        .ListSubItems.Add , , Trim(rs.Fields("OTHER_SIDE"))
        .ListSubItems.Add , , Trim(rs.Fields("MIN_HRS"))
        .ListSubItems.Add , , "-1" 'no action has been taken
    End With
    ListView1(iLineIdx).Refresh
    rs.MoveNext
Next
rs.Close
Set rs = Nothing

For intLoop = ListView1.LBound To ListView1.UBound
Call lvAutosizeControl(ListView1(intLoop))
Next intLoop

'SET IT TO THE FIRST TAB
Me.SSTab1.Tab = 0

'refresh
Me.Refresh
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top