listview data not in view

Hi Experts,

I am using the code below to load a listview on a form with records held in a memo field these records are kept as cvs records each record also being seperated by a comma each record has eight values the code strips out the last two fields in the array and builds the listview with the data(szGoodsDesc fields =
"998899, Battery Acid 5000 Ltr, 5, Euro Pallets         Stackable, 1200, 600, 1000, 5000,
888997766, Car Widget No5 10000, 10, Standard Pallets  Stackable, 1200, 1200, 1000, 1000,
" )
Loadlist.Clear()
                Dim cntr As Integer = 0
                Dim LoadArray(0, 8) As String
                sSeltxt = rst.Fields("szGoodsDesc").Value
                aryInputs = Split(sSeltxt & ",", ",") 'breaks it up by commas.
                Dim xx As Integer, X As Integer
                i = 0
                X = UBound(aryInputs)
                X = X / 8
                Dim y As Integer = 1
                Do While y < X
                    For i = LBound(aryInputs) To X * 8 removes extra fields from the array
                        xx = i
                        If (xx) > 7 And cntr = 1 Then xx = xx - 8
                        If (xx) > 7 And cntr = 2 Then xx = xx - 16
                        aryBits = Split(aryInputs(i), ",") 'Splits the item at the = character
                        sSeltxt = aryBits(0) 'Gets current csv and assigns to appropriate textbox
                        LoadArray(0, xx) = sSeltxt
                        If xx = 7 Then  code to make headers
                            ListViewMakeColumnHeaders(Me.Loadlist, _
                        "Part Number", HorizontalAlignment.Left, _
                        "Description", HorizontalAlignment.Left, _
                        "Num Pallets", HorizontalAlignment.Left, _
                        "Packaged", HorizontalAlignment.Left, _
                        "L", HorizontalAlignment.Center, _
                        "W", HorizontalAlignment.Center, _
                        "H", HorizontalAlignment.Center, _
                        "KG", HorizontalAlignment.Center)
                            Loadlist.BeginUpdate()
 code to make listview records
                            ListViewMakeRow(Me.Loadlist, _
                                                                                                   LoadArray(0, 0), _
                                                                                                   LoadArray(0, 1), _
                                                                                                   LoadArray(0, 2), _
                                                                                                   LoadArray(0, 3), _
                                                                                                   LoadArray(0, 4), _
                                                                                                   LoadArray(0, 5), _
                                                                                                   LoadArray(0, 6), _
                                                                                                   LoadArray(0, 7) _
                                                                                                   )
                            Me.Loadlist.EnsureVisible(cntr)
                            cntr = cntr + 1
                        End If
                    Next
                    y = y + 1
                Loop
            End With
            Me.Loadlist.EndUpdate()

            Me.Loadlist.Columns(0).Width = 80
            Me.Loadlist.Columns(1).Width = 180
            Me.Loadlist.Columns(2).Width = 80
            Me.Loadlist.Columns(3).Width = 50
            Me.Loadlist.Columns(4).Width = 50
            Me.Loadlist.Columns(5).Width = 50
            Me.Loadlist.Columns(6).Width = 50
            Me.Loadlist.Height = 65
            Me.ToTweight.Top = Me.Loadlist.Bottom

            If Me.Loadlist.Items.Count <= 5 Then
                Me.Loadlist.Height = (Me.Loadlist.Items.Count * 17) + 40
                Me.Height = Me.Height + 18
End if

When the code is ran the everthing appears ok but the listview appears empty, if I close the form and re-run hey presto the records are exactly as they should be. Why does the listview records not appear when the form is first populated nothing changes either in code or in the record betweeen the two instances?

Regards,
Joe
LVL 1
JoeBo747Asked:
Who is Participating?
 
EDDYKTCommented:
>>loadlist.clear() I have changed to loadlist.items.clear() . This is to clear the list between load events. ( loadlist is on form2 and is loaded when an item is selected on form1 and a button clicked)

if it is on the form2, you should do something like

load form2
' propulate the listview
form2.show

0
 
digitalZoCommented:
Try debugging using breakpoint to see in what sequence is it initally not displaying the records when the form is first run.
0
 
JoeBo747Author Commented:
Hi digitalZo,

I've debugged the procedure followed through the code and on both the first load and second load the code appears to load in exactly the same way. The only difference being that on the first load after the project is launched  the list doe's not appear populated (although if i do "msgbox(.recorcount)" i get a positive return) and on all other calls the listview shows records. Strange eh?

Regards,
Joe
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
EDDYKTCommented:
without seeing your full code, it is hard to say

1. Loadlist.Clear()
doesn't look like listview to me, if listview it should be Loadlist.Listitems.Clear

2. aryInputs = Split(sSeltxt & ",", ",") 'breaks it up by commas.
don't understand why to put extra , before split the string

3. do you have on error resume next?
comment it out
0
 
JoeBo747Author Commented:
Hi EDDYKT

Thanks for your response,  in answer to your points raised:

1.      loadlist.clear() I have changed to loadlist.items.clear() . This is to clear the list between load events. ( loadlist is on form2 and is loaded when an item is selected on form1 and a button clicked)
2.      I tried using vbcrlf after each 8 fields when the memo field is populated with the csv file. This resulted in the first field in record two being concatenated with the last field in record1, the extra , is dealt with by the code.
3.      I have no resume next present in the code.

The rest of the code loads data into other controls on the form from the same recorset that populates loadlist.

Regards
Joe
0
 
JoeBo747Author Commented:
Hi EDDYKT

Thanks for your help,  I have populated the listview from form1 and then opened the form, all is well thankyou!

Regards
Joe
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.