Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics 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 18th, 2006, 06:57 PM
Authorized User
Join Date: Jan 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default ListView Control / Text Field Error

Hi! Can anyone help me here?

I've created a ListView control with Text Fields below that update with table data everytime the ListView's selected item changes. The problem I have is, if I hold down the Down Arrow Key, the text fields update for a bit then the Database (it's Access 2002) returns a message:

"Unspecified Error"

I guess it must be to do with the ListView's message queue becoming overloaded with muliple calls to the database, so can anyone help me with a work around?

Thanks in advance

Old January 20th, 2006, 09:33 PM
Registered User
Join Date: Jan 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to ChinaWolf

 Is Your meaning wanting get data from database and refresh the listview control???
dim rst as new adodb.recordset
dim ccount as integer
 do while not rst.eof
    listview.listitems.add ccount,,rst.fields(1)

Old January 22nd, 2006, 08:50 AM
Authorized User
Join Date: Jan 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts

Hi ChinaWolf,

No all I was doing was trying to populate 3 text fields on the same form, as a ListView control that was displaying the selected line of data (Single Select mode). I was working from an example in the Beginning VB Databases book which on a change of selection in the ListView (ListView Click), went off to the database to retrieve the results before it populated the text fields below. What I was finding was if I permanently held down either the UP or DOWN arrow keys to change the selection, Access couldn't keep up with the database calls and displayed an 'unspecified error' message.

Because my ListView had all the necessary info for the text controls I finally managed to find the correct work around (I think).

If mylistviewctrl.SelectedItems.Count > 0
   'Populate text fields
   mytxtfield1 = mylistviewctrl.SelectedItems(0).Text
   mytxtfield2 = mylistviewctrl.SelectedItems(0).SubItems(1).Text
   mytxtfield3 = mylistviewctrl.SelectedItems(0).SubItems(2).Text
End If

It was the SubItems collection of the ListViewItem that I didn't know how to access. Everything seems to work now, and I don't get the database error message from Access. Is my code correct now?


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with ListView Control in C# jiggsroger C# 2005 7 April 7th, 2008 04:25 AM
About Listview control yuetqu BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 1 August 15th, 2006 04:56 AM
ListView Control JelfMaria VB How-To 4 May 5th, 2005 12:39 AM
Aligning Text in a Listview Control? xgbnow VB How-To 1 September 30th, 2004 06:37 AM
Edit text in ListView control pavel Pro VB 6 4 September 29th, 2004 02:32 AM

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