Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Listview Add Property blanks out Listview

Posted on 2001-06-26
9
Medium Priority
?
268 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
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

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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 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

705 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