?
Solved

listview data not in view

Posted on 2007-10-11
6
Medium Priority
?
174 Views
Last Modified: 2013-12-26
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
0
Comment
Question by:JoeBo747
  • 3
  • 2
6 Comments
 
LVL 10

Expert Comment

by:digitalZo
ID: 20055645
Try debugging using breakpoint to see in what sequence is it initally not displaying the records when the form is first run.
0
 
LVL 1

Author Comment

by:JoeBo747
ID: 20055778
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
 
LVL 26

Expert Comment

by:EDDYKT
ID: 20056092
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Author Comment

by:JoeBo747
ID: 20056845
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
 
LVL 26

Accepted Solution

by:
EDDYKT earned 2000 total points
ID: 20057835
>>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
 
LVL 1

Author Comment

by:JoeBo747
ID: 20058248
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question