Introduction.
In this episode of the TreeView Control Tutorial, we introduce the Microsoft Access ListView Control Project. The primary objective is twofold:
-
Populate the TreeView Control with Product Category items.
-
When a Category Node is selected, filter the related Product records from the Products Table and display them in the ListView Control.
Each Product record is presented with its field values arranged neatly across multiple columns, making the data easier to browse and analyze.
We are familiar with TreeView, ImageList, and ImageCombo Controls and worked with them in earlier Episodes.
The ListView Control will display data from three selected fields, arranged across three separate columns. Each column will include a header and additional properties such as report icons and tooltip text.
Since a Product record contains several fields, displaying all of them in the limited space of the ListView Control is not practical. Instead, the ListView will serve as a concise overview. When a user selects an item in the ListView, a separate Form will open, showing the complete details of the chosen Product record.
In summary, this project demonstrates how to integrate the TreeView, ListView, and ImageList Controls to create a structured and interactive interface for browsing and managing product data.
The ListView Control shares many characteristics with the Microsoft Access ListBox Control. Like the ListBox, it can display multiple columns of related values, each neatly arranged under its respective column header. The Column Width property for each column ensures that the field values have adequate space for proper display. In addition, each ListView item is interactive—responding to clicks—allowing you to trigger further actions such as opening a Form, running a Report, executing a Macro, or calling other functions as needed.
Links to the earlier Tutorial Sessions.
- Microsoft TreeView Control Tutorial.
- Creating an Access Menu with a TreeView Control.
- Assigning Images to TreeView Control.
- Assigning Images to TreeView Control-2, (creating ImageList Control shareable with other Projects.)
- TreeView Control Check-Mark Add, Delete Nodes.
- TreeView ImageCombo Drop-Down Access Menu.
- Re-arrange TreeView Nodes by Drag and Drop.
Articles on Access ListBox Control.
In Microsoft Access, the ListBox Control has been a versatile tool for displaying information in many different contexts. We have explored its use in several creative ways—for example:
-
Designing custom-made Form Wizards and Report Wizards.
-
Creating Hyperlinks within ListBox items.
-
Generating list items dynamically from the source data of another ListBox.
-
Displaying a file list from external sources inside the ListBox.
-
Populating the ListBox with the output of the Filter() Function.
These are just a few of the techniques we have previously experimented with using the Access ListBox. For detailed walkthroughs, explore the linked articles below.
-
List-Box and Date Part One.
List-Box and Date Part Two.
The ListView with TreeView Control Demo Image.
The Demo Image View of Form, with TreeView and ListView Controls:
The ListView Demo Form in Design View.
Designing the Form frmListView.
Creating the Form
frmListView
with TreeView, ListView, and ImageList Controls-
Create a New Form
-
Open your database and create a new form.
-
Save the form with the name frmListView.
-
-
Insert a TreeView Control
-
From the ActiveX Controls List, insert a TreeView Control on the left side of the Detail Section.
-
Change its Name property to
TreeView0
. -
In the Property Sheet, set:
-
Width: 6.614 cm
-
Height: 9.709 cm
-
-
-
Insert a ListView Control
-
From the ActiveX Controls List, insert a ListView Control to the right side of the TreeView.
-
Change its Name property to
ListView0
. -
Set its dimensions:
-
Width: 12.462 cm
-
Height: 9.709 cm
-
-
Position it close to the TreeView, keeping the top edges aligned.
-
-
Insert an ImageList Control
-
From the ActiveX Controls List, insert an ImageList Control on the right side of the ListView.
-
Change its Name property to
ImageList3
.
-
Note on Missing Controls
If you cannot find TreeView, ListView, or ImageList in the ActiveX controls list, you need to add the Microsoft Windows Common Controls (MSCOMCTL.OCX) reference:
-
Open the VBA Editor (
Alt + F11
). -
Go to Tools → References.
-
Locate and attach MSCOMCTL.OCX (Microsoft Windows Common Controls).
For detailed steps, refer to the TreeView Control Tutorial (first link at the top of this page). That guide explains how to register and add MSCOMCTL.OCX to your Access References.
Reusing the ImageList Control
If you have already downloaded the Demo Database (from the 4th link at the top):
-
Open that database.
-
Locate a form that already contains an ImageList Control.
-
Open the form in Design View.
-
Copy the ImageList Control to the Clipboard.
-
Close the Demo Database and return to your current project.
-
Open frmListView in Design View and paste the ImageList Control.
-
Rename it to ImageList3.
👉 If your copied ImageList already contains preloaded images, you can skip the next six steps (for manually adding images) and continue directly from Step 7.
-
Uploading Images into ImageList Control.
Adding Images to the ImageList Control
If you inserted the ImageList Control directly from the ActiveX Controls list (instead of copying from the demo database), you can upload your own images. Follow these steps:
-
Open ImageList Properties
-
Right-click on the ImageList Control.
-
From the shortcut menu, highlight ImageListCtrl_Object and select Properties.
-
-
Set the Image Size
-
On the General tab, select 16 × 16 as the image size option.
⚠️ Caution: Once images are uploaded, you cannot change the image size. -
If you later decide on a different size, you must remove all images, select a new size, and re-upload the images.
-
-
Upload Images
-
Switch to the Images tab.
-
Click the Insert Picture button.
-
Browse and select an image file from your computer.
-
Supported formats include BMP, PNG, JPG, JPEG, and TIFF.
-
-
The image will be resized to 16 × 16 pixels.
-
Large images may lose quality when reduced.
-
-
-
Assign Index and Key Values
-
Each image is automatically assigned an Index number.
-
Enter a unique Key name for the image in the Key field.
-
⚠️ Key names are case sensitive.
-
You can use either the Index number or the Key name when assigning images to TreeView Nodes or ListView Items.
-
-
-
Repeat as Needed
-
Upload as many images as required (typically 4–5 for this project).
-
Once ready, you can copy and reuse this ImageList Control in other projects.
-
-
Finalize
-
When you are finished uploading, click OK to close the Properties dialog.
-
Add an Exit Button
-
Insert a Command Button at the bottom of the form.
-
Set its Name property to:
cmdExit
. -
Set its Caption property to: Exit.
Save the Form
-
Save the form as frmListView with all the changes.
Preparing Demo Tables for TreeView–ListView Example
To demonstrate how the ListView Control works together with the TreeView Control, we will create two simple tables based on the Products table from the Northwind sample database.
1. Table: lvCategory
-
This table will hold the category groupings of products, which will be displayed as TreeView Nodes.
-
A new field named BelongsTo (Numeric) has been added.
-
This field is used to establish parent–child relationships within the same table.
-
For example, if a record’s '
BelongsTo'
Field-value is4 then
the record is a child node of the record with ID = 4.
-
2. Sample Data in lvCategory
-
Four new records were added to the table.
-
The first two records have their
BelongsTo
value set to 4, making them child nodes of record ID 4. -
The last two records have their
BelongsTo
value set to 10, making them child nodes of record ID 10.
-
-
In the records with ID = 4 and ID = 10, the Product Name/Description indicates that these categories contain multiple groups of items.
-
These groups are now split into separate child categories so they can appear under the correct parent node in the TreeView.
-
3. Table: lvProducts
-
This table holds the product details linked to the categories.
-
The
ParentID
of the product records have been updated to point to the new sub-category records created inlvCategory
. -
Only one of the original category groups was left unchanged, due to specific preference considerations.
4. Relationship Summary
-
lvCategory
provides the TreeView nodes (parent and child categories). -
lvProducts
provides the ListView items linked to each selected category node.
👉 At this stage, the lvCategory
table serves as the backbone for TreeView navigation, while the lvProducts
table supplies the detailed product records displayed in the ListView.
The lvProducts Table has about 45 records. The Table image, with a few sample records, is given below for reference:
Working with Two Tables.
Before moving forward, let’s take a closer look at the two tables and how they relate to each other within the TreeView and ListView controls.
Up to this point, we have only worked with a single table, where the Node Key, Description, and ParentID fields were all stored together. This allowed us to establish parent–child relationships within the same table and display them as nodes in the TreeView.
If you have followed the earlier tutorial sessions, you should already have a good understanding of how these self-referencing relationships work within one table.
Now, we are moving a step further. We will see how two different tables—lvCategory
and lvProducts
—are linked together:
-
The TreeView Control will display the category hierarchy from the
lvCategory
table. -
The ListView Control will display the related product details from the
lvProducts
table, based on the currently selected TreeView node.
First, let’s examine the lvCategory
table.
-
This table includes a BelongsTo field, which is populated in the last four records.
-
These four records represent child nodes of record IDs 4 and 10 in the
lvCategory
table. -
In the TreeView Control, they will appear as child nodes under the corresponding parent nodes:
-
Canned Fruit & Vegetables (ID = 4)
-
Dried Fruits & Nuts (ID = 10)
-
Next, let’s look at the lvProducts
table.
-
This table contains a ParentID field.
-
For each Category Item in the
lvCategory
table, there is one or more Product Items in thelvProducts
table. -
The ParentID value in the
lvProducts
refers directly to the CID (Category ID) in thelvCategory
table.
In other words:
-
Every product record in the ListView Control, grouped by the same ParentID, belongs to the corresponding category record in the
lvCategory
table with the same CID value.
⚠️ Note: Manually creating both these tables from the original Products table can be time-consuming. If you have been following this tutorial, you may instead download the Demo Database using the link provided at the end of this page.
-
Simply import the
lvCategory
andlvProducts
tables into your current project database. -
This way, you can build the project directly without reconstructing the tables from scratch.
-
Later, when your project is complete, if you face any issues, you can always refer back to the Demo Database for validation and troubleshooting.
The Form Module VBA Code.
Open the frmListView form in Design View.
Display the Class Module of the Form.
Copy and paste the following full VBA Code into the Module and press Ctrl+S to save the Code.
Option Compare Database Option Explicit Dim tv As MSComctlLib.TreeView Dim lvList As MSComctlLib.ListView Dim imgList As MSComctlLib.ImageList Const Prfx As String = "X" Private Sub Form_Load() Dim db As DAO.Database Dim tbldef As TableDef Set tv = Me.TreeView0.Object tv.Nodes.Clear Set imgList = Me.ImageList3.Object With tv .Font.Size = 9 .Font.Name = "Verdana" .ImageList = imgList 'assign preloaded imagelist control End With Set db = CurrentDb Set tbldef = db.TableDefs("lvProducts") Set lvList = Me.ListView0.Object lvList.ColumnHeaders.Clear lvList.ListItems.Clear lvList.Icons = imgList 'Initialize ListView & Column Headers Property Values With lvList .ColumnHeaderIcons = imgList .Font.Size = 9 .Font.Name = "Verdana" .Font.Bold = False .View = lvwReport .GridLines = True 'ColumnHeaders.Add() Syntax: 'lvList.ColumnHeaders.Add Index, Key, Text, Width, Alignment, Icon 'Alignment: 0 - Left, 1 - Right, 2 - Center .ColumnHeaders.Add 1, , tbldef.Fields(1).Name, 2600, 0, 5 .ColumnHeaders.Add 2, , tbldef.Fields(3).Name, 2600, 0, 5 .ColumnHeaders.Add 3, , tbldef.Fields(4).Name, 1440, 1, 5 End With Set db = Nothing Set tbldef = Nothing LoadTreeView 'Create TreeView Nodes End Sub Private Sub LoadTreeView() Dim Nod As MSComctlLib.Node Dim firstCatID As Long Dim strCategory As String Dim strCatKey As String Dim strProduct As String Dim strPKey As String Dim strBelongsTo As String Dim strSQL As String Dim db As DAO.Database Dim rst As DAO.Recordset 'Initialize treeview nodes tv.Nodes.Clear 'Initialize Listview nodes While lvList.ListItems.Count > 0 lvList.ListItems.Remove (1) Wend strSQL = "SELECT lvCategory.CID, lvCategory.Category, " strSQL = strSQL & "lvcategory.BelongsTo FROM lvCategory ORDER BY lvCategory.CID;" Set db = CurrentDb Set rst = db.OpenRecordset(strSQL, dbOpenSnapshot) If Not rst.BOF And Not rst.EOF Then rst.MoveFirst firstCatID = rst!CID Else Exit Sub End If ' Populate all Records as Rootlevel Nodes Do While Not rst.BOF And Not rst.EOF strCatKey = Prfx & CStr(rst!CID) strCategory = rst!Category Set Nod = tv.Nodes.Add(, , strCatKey, strCategory, 1, 2) Nod.Tag = rst!CID rst.MoveNext Loop 'In the second pass of the the same set of records 'Move Child Nodes under their Parent Nodes rst.MoveFirst Do While Not rst.BOF And Not rst.EOF strBelongsTo = Nz(rst!BelongsTo, "") If Len(strBelongsTo) > 0 Then strCatKey = Prfx & CStr(rst!CID) strBelongsTo = Prfx & strBelongsTo strCategory = rst!Category Set tv.Nodes.Item(strCatKey).Parent = tv.Nodes.Item(strBelongsTo) End If rst.MoveNext Loop rst.Close ' Populate ListView Control with Product details ' of the first Category Item LoadListView firstCatID End Sub Private Sub LoadListView(ByVal CatID) Dim strProduct As String Dim strPKey As String Dim intCount As Integer Dim tmpLItem As MSComctlLib.ListItem Dim db As DAO.Database Dim rst As DAO.Recordset Dim strSQL As String ' Initialize ListView Control While lvList.ListItems.Count > 0 lvList.ListItems.Remove (1) Wend strSQL = "SELECT lvProducts.* FROM lvProducts " strSQL = strSQL & "WHERE (lvProducts.ParentID = " & CatID & ") " strSQL = strSQL & "ORDER BY lvProducts.[Product Name];" 'Open filtered Products List for selected category Set db = CurrentDb Set rst = db.OpenRecordset(strSQL, dbOpenSnapshot) Do While Not rst.BOF And Not rst.EOF intCount = intCount + 1 strProduct = rst![Product Name] strPKey = Prfx & CStr(rst!PID) 'List Item Add() Syntax: 'lvList.ListItems.Add Index,Key,Text,Icon,SmallIcon Set tmpLItem = lvList.ListItems.Add(, strPKey, strProduct, , 3) 'first column lvList.ForeColor = vbBlue 'List second column sub-item Syntax: 'tmpLItem.ListSubItems.Add Column - Index, Key, Text, ReportIcon, ToolTipText tmpLItem.ListSubItems.Add 1, strPKey & CStr(intCount), Nz(rst![Quantity Per Unit], ""), 6 'List third column sub-item tmpLItem.ListSubItems.Add 2, strPKey & CStr(intCount + 1), Format(rst![list Price], "0.00"), 6, "In Local Currency." rst.MoveNext Loop Set db = Nothing Set rst = Nothing If intCount > 0 Then lvList.ListItems(1).Selected = True End Sub Private Sub TreeView0_NodeClick(ByVal Node As Object) Dim Cat_ID As String Cat_ID = Node.Tag LoadListView Cat_ID End Sub Private Sub ListView0_Click() Dim lvKey As String, lvLong As Long Dim Criterion As String lvKey = lvList.SelectedItem.Key lvLong = Val(Mid(lvKey, 2)) DoCmd.OpenForm "ProductDetails", , , , , , lvLong End Sub Private Sub cmdExit_Click() DoCmd.Close End Sub
Let’s review the code and understand its functionality.
In the global declaration area, the following object variables are declared:
-
TreeView Object (tv)
-
ListView Object (lvList)
-
ImageList Object (imgList)
Additionally, a constant named Prfx is declared with the value "X"
, which is used as the prefix for Node Keys.
When the form frmListView
is opened, the Form_Load() event procedure executes.
-
Within this procedure, the database object (db) and TableDef object variable (tbldef) are declared.
-
The TreeView0 control on the form is assigned to the variable tv.
-
The statement
tv.Nodes.Clear
initializes the TreeView control instance by clearing any existing nodes. -
Next, the imgList variable is initialized with the ImageList3 control on the form.
TreeView Control Display Font and ImageList Properties.
The following statements configure the TreeView control’s font settings (Font Name and Font Size) and assign its ImageList property to the imgList
object. This allows the TreeView nodes to display images using either the Image Key names or the Image Index numbers.
With tv .Font.Size = 9 .Font.Name = "Verdana" .ImageList = imgList 'assign preloaded imagelist control End With
The ListView Control Property Settings and Column Headers.
After that, the following segment of the Code Initializes the ListView Control and assigns its Property values.
Set db = CurrentDb Set tbldef = db.TableDefs("lvProducts") Set lvList = Me.ListView0.Object lvList.ColumnHeaders.Clear lvList.ListItems.Clear lvList.Icons = imgList 'Initialize ListView & Column Headers Property Values With lvList .ColumnHeaderIcons = imgList .Font.Size = 9 .Font.Name = "Verdana" .Font.Bold = False .View = lvwReport .GridLines = True 'ColumnHeaders.Add() Syntax: 'lvList.ColumnHeaders.Add Index, Key, Text, Width, Alignment, Icon 'Alignment: 0 - Left, 1 - Right, 2 - Center .ColumnHeaders.Add , , tbldef.Fields(1).Name, 2600, 0, 5 .ColumnHeaders.Add , , tbldef.Fields(3).Name, 2600, 0, 5 .ColumnHeaders.Add , , tbldef.Fields(4).Name, 1440, 1, 5 End With Set db = Nothing Set tbldef = Nothing
The variable tbldef
is assigned with the table definition of the lvProducts
table. Its field names are used as the ListView column headers, ensuring that each column header corresponds to a table field.
Since column headers can also display icons, the imgList
Object is assigned to the lvList.ColumnHeaderIcons
property.
Next, the font name, size, and style are customized for the ListView control, in case the default settings are not suitable.
The overall appearance of the ListView is determined by its View
property. In this project, we use lvwReport
(value = 3), which provides the most features—column headers, grid lines, and image support. You may also experiment with other values (0, 1, or 2) to explore the different display styles.
We selected three fields from the lvProducts
table—Product Name, Quantity Per Unit, and List Price—to display in three separate columns of the ListView control.
The Column Width is specified in pixels. The Alignment property accepts values from 0
to 2
, which defines text alignment within each column:
-
0
– Left align -
1
– Right align -
2
– Center align
To define the column headers, the lvList.ColumnHeaders.Add()
is used with the following syntax:
Using this method, we added all three column headers—Product Name, Quantity Per Unit, and List Price—before inserting any data into the ListView control. This step is performed in the Form_Load() event procedure, rather than during item population, to ensure the structure is ready in advance.
Next, the Subroutine LoadTreeView()
is called to create the TreeView nodes. As discussed in earlier tutorials, this task is handled in two stages for clarity and maintainability.
After declaring the required variables, both the TreeView and ListView controls are initialized. Immediately upon opening the lvCategory
recordset, the first record’s CID (Category ID) value is stored in the firstCatID
variable for later reference.
Finally, all records from the lvCategory
table are added to the TreeView control as root-level nodes.
In the second pass through the same set of records, the code evaluates the BelongsTo field.
-
If BelongsTo is empty, the node remains at the root level.
-
If a value exists, that value represents the ParentID of another root-level node. Using this ParentID, the current node is placed under its corresponding parent as a child node.
This two-step approach to populating the TreeView ensures proper hierarchical structure. I explained this concept in detail in an earlier episode, and we confirmed its behavior through hands-on experiments in the previous tutorial session.
After closing the recordset object, the procedure calls the LoadListView(ByVal CatID) subroutine. The CID value of the first category record—saved earlier in the firstCatID
variable—is passed as a parameter.
Inside the LoadListView Subroutine, the 'CID
' value is used in the strSQL filter string to retrieve only those product records that belong to the selected category. In this way, the ListView displays only the products related to the current category.
From the filtered product records, we use only four fields: PID, Product Name, Quantity Per Unit, and List Price. The PID field serves as the key value for each item, but is not displayed in the ListView.
To display the other three fields, the ColumnHeaders.Add()
is called three times, once for each column header.
Note:
In these statements, we have not specified a Key parameter for the column headers. Instead, the system automatically assigns an Index value. Since we do not plan to manipulate the column headers after they are created, using the index is sufficient. However, when loading product records into the ListView, we must ensure that the field values are inserted in the same sequence as the column headers.
Populating the ListView Control with Product Values in Columns.
To display product records in the ListView control, we use two sets of Add()
methods:
-
ListItems.Add()
– for the first column value. -
ListSubItems.Add()
– for all subsequent column values.
Since the ListView requires a unique key for each item, we use the PID field along with a counter variable (intCount
). The counter is incremented in each Do While...Loop
cycle, and its current value is appended to the PID to guarantee uniqueness in the ListSubItems.Add()
method.
Syntax: Adding the first column
-
Index – Position of the item in the ListView.
-
Key – Unique identifier (we use
PID & intCount
). -
Text – The display value for the first column (e.g., Product Name).
-
Icon / SmallIcon – Optional parameters for assigning images.
‘lvList.ListItems.Add Index,Key,Text,Icon,SmallIcon
Set tmpLItem = lvList.ListItems.Add(, strPKey, strProduct, , 3)
The ListItems.Add()
The ListView works very much like the Nodes.Add()
method in the TreeView control.
We first declare an ListItem
object variable (tmpLItem
) to hold a reference to the item returned by ListItems.Add()
. This reference is then used to attach sub-items to that row.
Adding SubItems
The ListSubItems.Add()
It is slightly different in syntax. Each sub-item also requires a unique key, so we use the product key (strPKey
) combined with the loop counter (intCount
).
For example:
-
First sub-item → Key =
strPKey & CStr(intCount)
-
Second sub-item → Key =
strPKey & CStr(intCount + 1)
Syntax Example
Here:
-
tmpLItem
anchors the row. -
Each
ListSubItems.Add()
attaches a value to the same row, ensuring the sequence of fields matches the sequence of column headers. -
The counter (
intCount
) keeps sub-item keys unique, avoiding conflicts.
The ListSubItems.Add()
supports five parameters:
In our example:
-
Index → Position of the sub-item (here,
2
) -
Key → Unique identifier (
strPKey & CStr(intCount + 1)
) -
Text → Display text (List Price formatted as
"0.00"
) -
ReportIcon → Image index from the assigned
imgList
(here,6
) -
ToolTipText → Tooltip shown when hovering over the sub-item (used here only for the last column).
Important Note
All column-related features (headers, alignment, icons, tooltips, etc.) work only when the ListView View
Property is set to 3 (lvwReport)
.
-
In other views (
0
,1
, or2)
Only the first column is displayed; sub-items and their settings are ignored.
The tooltip text appears when the mouse pointer hovers over the last column.
For all three columns (the ListItem
and its ListSubItems
), The Add()
uses the same record’s PID as the base key. However, since each column of the same record requires a unique key value, the counter variable intCount
is incremented and concatenated with the PID. This ensures every column entry has a distinct key.
With this approach, all product records related to the selected category are displayed in the ListView control.
Separate Form to Display Full Product Record Details.
Because the lvProducts table contains more fields than can be accommodated within the ListView’s width, the ListView ItemClick event is used to open a separate form, ProductDetails, where the complete record information is displayed.
The image below shows the form with all details of the selected product:
The ListView0_Click() Event Procedure.
Private Sub ListView0_Click() Dim lvKey As String, lvLong As Long Dim Criterion As String lvKey = lvList.SelectedItem.Key lvLong = Val(Mid(lvKey, 2)) DoCmd.OpenForm "ProductDetails", , , , , , lvLong End Sub
The ProductDetails Form.
In the Form_Open() event procedure, the value passed through OpenArgs is used to build a filter criterion. This ensures that only the selected product record is retrieved and displayed on the ProductDetails form.
The form’s module code is as follows:
Option Compare Database Option Explicit Private Sub cmdClose_Click() DoCmd.Close End Sub Private Sub Form_Open(Cancel As Integer) Dim lngID As Long lngID = Nz(Me.OpenArgs, 0) If lngID > 0 Then Me.Filter = "id = " & lngID Me.FilterOn = True End If End Sub Private Sub Form_Unload(Cancel As Integer) With Me .Filter = "" .FilterOn = False End With End Sub
The ProductDetails form retrieves its source data from the filtered recordset, using the PID (Product ID) value passed through OpenArgs. This ensures that only the details of the selected product are displayed.
The original Products table was taken from the Northwind.accdb sample database and renamed as ProductsNew for this project.
I hope you enjoyed working through this ListView control project. More tutorials with advanced ListView features are coming soon.
👉 Download the demo database from the link below, and happy List Viewing!
Hi, I find your arguments very interesting. I would like to know how I can highlight the first row found based on the contents (key) of a text box, please? Thank you
ReplyDelete1. Design a Tabular Form to replace in place of the Columnar Form.
ReplyDelete2. Replace the Form_Open() Event Subroutine with the following Form_Load() Subroutine Code and try.
Private Sub Form_Load()
Dim rst As Recordset
Dim lngID As Long
lngID = Nz(Me.OpenArgs,0)
If lngID > 0 Then
Set rst = Me.RecordsetClone
rst.FindFirst "ID = " & lngID
If Not rst.NoMatch Then
Me.BookMark = rst.BookMark
End If
End If
End Sub
Right, but I was referring to the ListView control. I need to search and highlight the row based on the contents of a text box present in the form. Thank you
ReplyDeleteHi Sir, I've a fuw questions about the Listview please:
ReplyDeleteI drawn a form with a ListView and some fields connected to the ListView's recordset. I update the data of the selected row trought a Save button that reloads the ListView, but the data doesn't update, as if the command lvwList.ListItems.Clear not working. If I close the form and reopen it I see the updated ListView. Can you help me? Thank you
Hi, I solved the problem with a simple me.refresh. I find your topics very interesting which improve my projects. Thank you very much.
ReplyDeleteI am glad that you found the solution yourself. Keep it up.
DeleteHi Stefano, I am sorry that I could not respond to your query and was busy with some social engagements.
ReplyDeleteAs you are aware that the ListView Control's contents are loaded by Clicking on the Category Node of the TreeView Control, and the data loading process is different than we load data into the Form. If the ListView record is edited through a different Form, the change may not reflect in the ListView immediately. If you click the TreeView Category Node a second time, the changed data will be reloaded into the ListView Control again.