Solved

Listview Add Property blanks out Listview

Posted on 2001-06-26
9
262 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
ID: 6228380
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
ID: 6228386
Woops, change the me.listview1's to lstBudgetLoadType

Zaphod.
0
 
LVL 1

Author Comment

by:lyners
ID: 6228445
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 1

Expert Comment

by:anup_s
ID: 6228623
I think this is a refresh problem
Try issuing the refresh method

- Anup
0
 
LVL 1

Author Comment

by:lyners
ID: 6228722
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
ID: 6228771
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
ID: 6228835
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
ID: 6509602
Check last entry.
0
 
LVL 2

Accepted Solution

by:
Lunchy earned 0 total points
ID: 6510096
Adding to PAQ
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

839 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