|
Subject:
|
ListView Control / Text Field Error
|
|
Posted By:
|
ExDb
|
Post Date:
|
1/18/2006 5:57:18 PM
|
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
|
|
Reply By:
|
ChinaWolf
|
Reply Date:
|
1/20/2006 8:33:56 PM
|
Is Your meaning wanting get data from database and refresh the listview control??? dim rst as new adodb.recordset dim ccount as integer listview.listitems.clear ccount=0 do while not rst.eof ccount=ccount+1 listview.listitems.add ccount,,rst.fields(1) listview.listitems.subitems(1)=rst.fields(2) ... rst.movenext loop
|
|
Reply By:
|
ExDb
|
Reply Date:
|
1/22/2006 7:50:19 AM
|
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?
ExDb
|