Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Listview Add Property blanks out Listview

Posted on 2001-06-26
9
Medium Priority
?
270 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…
Suggested Courses

885 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