help with listview population syntax

  • Thread starter Thread starter Ricky A.
  • Start date Start date
R

Ricky A.

can anyone help me with the basic syntax to populate a multi-column list
with data in Access 2002.
Thanks.
 
Is there a particular reason for using a listview? The Access Listbox
supports multi-column just fine.
 
Ricky A. said:
can anyone help me with the basic syntax to populate a multi-column list
with data in Access 2002.
Thanks.

You can adapt this code to your needs
======================
' Reset ListView Control and prepare column headers
Me!ListView.ListItems.Clear
With Me!ListView.ColumnHeaders
.Clear
.Add , , "Num.", 280
.Add , , "Type", 800
.Add , , "Note", 400, lvwColumnCenter
End With

' Create SQL statement used to fill recordset
strSQL = "SELECT * FROM <YouTableOrQuery>;"

Set rs = db.OpenRecordset(strSQL)

' Populate the data
If Err = conErrNoRecord Then
With Me!ListView.ColumnHeaders
.Clear
.Add , , "Records = None", 3600
End With
Set itmAdd = ListView.ListItems.Add()
itmAdd.Text = "No Record!"
Exit Sub
End If
While Not rs.EOF
Set itmAdd = ListView.ListItems.Add()
itmAdd.Text = rs!NUM
itmAdd.SubItems(1) = rs!Type
itmAdd.SubItems(2) = rs!Note
rs.MoveNext
Wend

====================

You need also to setup a reference to the Microsoft Windwos Common Controls
5.X (comctl32.ocx)

Sidnei Cordeiro
 
Back
Top