Solved

Listview Add Property blanks out Listview

Posted on 2001-06-26
9
264 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…

734 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