Solved

Listview Add Property blanks out Listview

Posted on 2001-06-26
9
256 Views
Last Modified: 2011-09-20
I have created a module that adds an item to a list view. Whenever I add an item the listview goes blank. It's as if all the records are there, just that all the lines are blank. Here is the code for adding an item;

Function AddItems(varAll As Variant, varProject As Variant, _
                  varSub_Project As Variant, varPhase As Variant, _
                  varDescription As Variant, _
                  varYear As Variant, varObjectRevenueSource As Variant, _
                  varAmount As Variant) As Boolean

On Error GoTo Err_AddItems

      Dim NewLine As ListItem

      ' Loop through recordset and add Items to the control.
      If IsNumeric(varAll) Then
          Set NewLine = lstBudgetLoadType.ListItems.Add()
          NewLine.Text = CStr(varAll)
      Else
          Set NewLine = lstBudgetLoadType.ListItems.Add()
          NewLine.Text = varAll
      End If
      NewLine.SubItems(1) = varProject
      NewLine.SubItems(2) = varSub_Project
      NewLine.SubItems(3) = varPhase
      NewLine.SubItems(4) = varDescription
      NewLine.SubItems(5) = varYear
      NewLine.SubItems(6) = varObjectRevenueSource
      NewLine.SubItems(7) = Format(varAmount, "Currency")

      NewLine.EnsureVisible
     
Exit_AddItems:
    AddItems = True
    Exit Function
   
Err_AddItems:
    Error_Routine "Form: Budget Load Add/Edit Entry", "AddItems"
    AddItems = False
    Exit Function

End Function

What I want the code to do is add an item to the listview and when the listview is made visable again, the item exists. I may be looking over something that's very easy. Any pointers?

Lyners
0
Comment
Question by:lyners
9 Comments
 
LVL 7

Expert Comment

by:Z_Beeblebrox
Comment Utility
Hi,

Try this:

Set NewLine = lstBudgetLoadType.ListItems.Add(,,varAll)

And make sure your listview is set to report mode with enough columns to hold all of your data. This can be done from the custom properties or from code.

Me.ListView1.View = lvwReport    Me.ListView1.ColumnHeaders.Add , , "Header"

Zaphod.
0
 
LVL 7

Expert Comment

by:Z_Beeblebrox
Comment Utility
Woops, change the me.listview1's to lstBudgetLoadType

Zaphod.
0
 
LVL 1

Author Comment

by:lyners
Comment Utility
Z,
I tried your suggestion, same result. What I have is a listview that I populate on load and everything is great. I click on a button to add record. The Listview is made invisable and the form (lying underneath) is displayed. The user enters the information into the form and then clicks add_record (The above code). When I make the list view visable again, all is blank. I can see the headers, but no data. The data appears to have vanished but all the lines exist?!?!?!. I have another button on the form to "Choose another record" (located on the "Form". If a user is editing a record, then can click this button to abort update and choose a different item. If I have the above problem happen, all I do is double click on any of the blank items (which brings up the form), then click on the "Choose Different Record" command button. When I do this, the listview is made available and all the records appear, even the ones that I added!

What could this be?

Lyners
0
 
LVL 1

Expert Comment

by:anup_s
Comment Utility
I think this is a refresh problem
Try issuing the refresh method

- Anup
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 1

Author Comment

by:lyners
Comment Utility
I tried refreshing. It didn't work. i tried to refresh the listview control, and I tried to refresh the form. No dice. It's really odd. It has something to do with the visable prerty. I also have a delete on this form and it works perfectly. The only difference between the code is for the delete I do not have to hide the listview control.
0
 
LVL 1

Author Comment

by:lyners
Comment Utility
I tried refreshing. It didn't work. i tried to refresh the listview control, and I tried to refresh the form. No dice. It's really odd. It has something to do with the visable prerty. I also have a delete on this form and it works perfectly. The only difference between the code is for the delete I do not have to hide the listview control.
0
 
LVL 1

Author Comment

by:lyners
Comment Utility
I have figured out my problem. The listview must be visable when adding items. I turned on the visability of the listview, added an item and there it was. If I shut of the visability, the listview would be blank when made visable after the add.

Thanks for everyones help!

I am going to ask EE to keep this question for future reference, but I am going to ask not to reward any points considering I solved it. Is everyone OK with that?
0
 
LVL 1

Author Comment

by:lyners
Comment Utility
Check last entry.
0
 
LVL 2

Accepted Solution

by:
Lunchy earned 0 total points
Comment Utility
Adding to PAQ
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now