Hi guys
I;m trying to move all my Listview content into a module because I have to call it several times and it becomes annoying having to type it a number of times. I'm a little stuck though. I've managed to move most of the listview code onto a module but I keep getting errors. See the code below: - Public Sub AddItem(lvwListView1 as listview)
-
ConnectDB
-
Dim lstNew As ListItem
-
Set rs = New ADODB.Recordset
-
rs.Open "SELECT * From Product Where ProductID like '" & ProductID & "%'", cn, adOpenDynamic, adLockOptimistic
-
'add to first column
-
Set lstNew = lvwListView1.ListItems.Add(, , rs.Fields("ProductID").Value)
-
'add to next column
-
lstNew.ListSubItems.Add , , rs.Fields("ProductName").Value
-
lstNew.ListSubItems.Add , , Quantity
-
lstNew.ListSubItems.Add , , rs.Fields("UnitPrice").Value
-
lstNew.ListSubItems.Add , , (rs.Fields("UnitPrice").Value * Val(Quantity))
-
rs.Close
-
End Sub
- Public Sub ReRunListview(lvwListView as listview)
-
Dim i As Long
-
Dim lvwItem As ListItem
-
For i = 1 To lvwListView1.ListItems.Count
-
Set lvwItem = lvwListView.ListItems.Add(, , lvwListView1.ListItems.item(i).Text)
-
lvwItem.SubItems(1) = lvwListView1.ListItems(i).SubItems(1)
-
lvwItem.SubItems(2) = lvwListView1.ListItems(i).SubItems(2)
-
lvwItem.SubItems(3) = lvwListView1.ListItems(i).SubItems(3)
-
lvwItem.SubItems(4) = lvwListView1.ListItems(i).SubItems(4)
-
Next
-
End Sub
The AddItem function will get the actual data from the database. Then I will call the ReRunListview function whenever I want to call it from another form.
But, when I run the code, the AddItem function works fine. It's when I get to the 'for statement' in the ReRunListview function I get the following error:
Runtime error 91 - Object variable or With block variable not set.
Any help will be greatly appreciated. :)
1 1533
All I can think of is that you must have called it without correctly passing a listview control, or something.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Dave Y |
last post by:
I am a newbie to C# and am having trouble trying to override a ListView
property method. I have created a new class derived from the Forms.Listview
and I cannot figure out the syntax to override ListView.Items.Add(), . I see
that it is a virtual method so it should be easy to do. If anyone can help I
would appreciate it greatly. I can do what I need to do in a different way
this would just make everything significantly cleaner and eaasier...
|
by: Derck |
last post by:
SORRY, for the crosspost, but I think I posted it in the wrong group!
Hello all,
I have a question.. I am tying to make a global listview class where other
listviews in my application points to, so when I change something in that
listview all listviews who points to that listview must be updated.. But I
don't have a idea why it isn't working..
I tried to make a singeton listview class and get a instance on the form
|
by: Nick |
last post by:
Hi there,
I'm trying to implement drag-drop for my listview control in large icon
view mode. Unfortunately the order of the items gets completely messed up
upon inserting the item back into the listview, removing the item obviously
keeps everything fine but the second I use insert the item is added to the
*end* of the listview. Does anyone have any tips on how I can solve this
issue??
Call Items.Remove(SourceItem)
|
by: gsb58 |
last post by:
Hi!
This saves data from column1 in a Listview to disk like: 2005-09-20.txt
I've come so far in my research:
Dim fs As New FileStream("C:\" &
MyCalendar.TodayDate.ToShortDateString() & ".txt",
FileMode.OpenOrCreate)
|
by: Wicksy |
last post by:
Hi all.
I have a VB.NET app with a loop running that is continually managing a
number of threads AND updating a ListView object depending on the results of
the worker threads.
The problem I have is that if I try to move (drag) the form's window around
the screen, or to scroll the ListView control, the loop pauses until I stop
dragging or scrolling. I want the loop to continue whilst I'm doing trivial
things like moving the window...
| |
by: Terry Olsen |
last post by:
Does anyone have an example of how I could print a ListView control? It'd
sure be easier to do this than to try to format the output in DrawStrings...
Thanks.
|
by: rb |
last post by:
Hi All,
Is there a property or method to keep the headercolumns from being
resized by the user
for a listview?
I am using Visual Basic in Visual Studio . net 2005
Thank you.
|
by: Brian Gaze |
last post by:
I have created a ListView control and have bound this to a datasource.
Within the ItemTemplate of the ListView I have added another ListViewControl
which is databound in the code behind. The idea is that when clicking on the
"Show details" button the ListView for the appropriate row binds in the
codebehind and displays the detail data for the selected row. I did
something similar with a gridview control previously, but want to be able to...
|
by: Lloyd Sheen |
last post by:
I was in a thread talking about how to populate a listview from a Linq
query. This got my curiosity up so I created a usercontrol which is a
listview which can be populated from a Linq query.
I has all the same properties / methods available to a listview but behind
the scenes it is really a virtual listview. It is quick to load (33K items
in less than a second including the query).
It can be sorted and uses the dynamic linq vb...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |