Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 25th, 2012, 01:07 AM
Registered User
 
Join Date: Jan 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access Recordset to listview

Hi,
I am getting an error while loading access table to listview, the error message is "Invalid Property Value"
Code:
Private Sub Form_Load()
Call addforqry("Select * from ltplan", ListView1)
End Sub

Public Sub addforqry(qry As String, lv As Control)
Dim i As Integer, cnt As Integer
Dim rd As New ADODB.Recordset
Dim cn As New ADODB.Connection
cn.Open "KEC1"
'Dim qry As String
'qry = "Select * from ltplan"
Set rd = cn.Execute(qry)
lv.ColumnHeaders.Clear
lv.ListItems.Clear
For i = 0 To rd.Fields.Count - 1
    lv.ColumnHeaders.Add , , rd.Fields(i).Name
Next
cnt = 1
If rd.BOF = False Then
Do Until rd.EOF
    lv.ListItems.Add cnt, , cnt
    For i = 0 To rd.Fields.Count - 1
        temp = rd(i)
        lv.ListItems(cnt).SubItems(i) = temp
        Next
        cnt = cnt + 1
        rd.MoveNext
        Loop
End If
Please help
Regards





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 25 Page 850 ListView ListView Frodo BOOK: Beginning Visual C# 2010 0 December 23rd, 2011 12:55 PM
How to access a recordset without connection? JelfMaria VB How-To 9 June 30th, 2005 12:01 AM
ADO Recordset to Access MDB sasidhar79 SQL Server ASP 1 June 23rd, 2004 02:15 AM
Recordset date insert in access kev_79 Access ASP 3 June 5th, 2003 12:49 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.