Article ID: 166912
Article Last Modified on 1/19/2007
Private Sub Command0_Click
Dim db As Database, rs As Recordset
Dim itmX As ListItem
Set db = CurrentDb()
Set rs = db.OpenRecordset("Employees", dbOpenDynaset)
' Toggle the Visible property of the control.
Me!ListView1.Visible = Not Me!ListView1.Visible
' Clear and then refill the control with data.
While Not rs.EOF
Set itmX = ListView1.ListItems.Add(, , CStr(rs![FirstName] ))
If Not IsNull(rs![LastName]) Then
itmX.SubItems(1) = CStr(rs![LastName])
End If
If Not IsNull(rs![BirthDate]) Then
itmX.SubItems(2) = rs![BirthDate]
End If
rs.MoveNext
Wend
End Sub
Name: ListView1
Width: 4"
Height: 2"
Private Sub Form_Open(Cancel As Integer)
Dim db As Database, rs As Recordset
Dim itmX As ListItem
Set db = CurrentDb()
Set rs = db.OpenRecordset("Employees", dbOpenDynaset)
ListView1.ColumnHeaders.Add, , "First Name", ListView1.Width/3
ListView1.ColumnHeaders.Add, , "Last Name", _
ListView1.Width/3, lvwColumnCenter
ListView1.ColumnHeaders.Add, , "Birthdate", _
ListView1.Width/3
ListView1.View = lvwReport
While Not rs.EOF
Set itmX = ListView1.ListItems.Add(, , CStr(rs![FirstName] ))
If Not IsNull(rs![LastName]) Then
itmX.SubItems(1) = CStr(rs![LastName])
End If
If Not IsNull(rs![BirthDate]) Then
itmX.SubItems(2) = rs![BirthDate]
End If
rs.MoveNext
Wend
End Sub
Private Sub Command0_Click()
Me!ListView1.Enabled = Not Me!ListView1.Enabled
End Sub
Additional query words: disappear reduce diminish
Keywords: kbbug kbinterop kbprogramming KB166912