设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 1579|回复: 2
打印 上一主题 下一主题

[ActiveX] 第一次使用ListView就出现问题,大家帮忙看看

[复制链接]
1#
发表于 2009-9-8 09:05:21 | 显示全部楼层
先加columnheaders才能加listitem
Private Sub Form_Load()
Dim syRecset As DAO.Recordset
Dim itemX As ListItem
Dim a As Integer
Dim strSql As String

ListV.ListItems.Clear
strSql = "SELECT * FROM Table1 "
Set syRecset = CurrentDb.OpenRecordset(strSql)
Debug.Print syRecset.RecordCount
For a = 1 To syRecset.Fields.Count
    ListV.ColumnHeaders.Add , , syRecset.Fields(a - 1).Name
Next
If syRecset.RecordCount > 0 Then
syRecset.MoveFirst
Do Until syRecset.EOF
    Set itemX = ListV.ListItems.Add()
    itemX.SubItems(1) = syRecset!AA
    itemX.SubItems(2) = syRecset!BB
    syRecset.MoveNext
Loop
Set syRecset = Nothing
End If
End Sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-15 23:34 , Processed in 0.104103 second(s), 24 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表