Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox scrolling moves Recordset position 1

Status
Not open for further replies.

paulgenga

Programmer
Jan 8, 2004
61
0
0
KE
Hi,

I have this problem of having my recordset changing positions while i scroll the list box using up/down arrows.

Please help. This is how I setfocus to the list box...

Code:
With List1
                .Clear
                 adoTmpRS.Open "select * from m_Ac order by ac_name", db, adOpenStatic, adLockReadOnly
                 For i = 1 To adoTmpRS.RecordCount
                     .AddItem adoTmpRS!ac_name
                     adoTmpRS.MoveNext
                 Next i
                 adoTmpRS.Close
                 .Text = grdDataGrid.Columns(ColIndex).Value
                 .Left = grdDataGrid.Columns(ColIndex).Left + 125
                 .Width = grdDataGrid.Columns(ColIndex).Width
                 .Top = grdDataGrid.Top + grdDataGrid.RowTop(grdDataGrid.Row) + grdDataGrid.RowHeight
                 .Visible = True
                 .SetFocus
             End With

How can I stop this from happenning.
Please help me.



 
Instead of doing a connected list box, you could disconnect it, by adding items to the list programatically...



Casper

There is room for all of gods creatures, "Right Beside the Mashed Potatoes".
 
Thanks Casper
However i dont understand. because "adoTmpRS" is just a temporary RS used to pupulate the list box then closes.
Again the list box has nothing directly linking is to the RS e.g. DataField or DataSource.

I haveonly tried to use it with a button on a DataGrid column to edit the field.value

Genga
 
Hi,

When you say:
paulgenga said:
recordset changing positions while i scroll the list box using up/down arrows.
I found that a bit vague, what is changing position if the recordset is temporary and closed after you populate the listbox? The listbox order?


One thought I had was that, if you answer yes to my last question, you might have the Sorted property of the Listbox set to True. This would cause the items (once programatically added to the listbox) to become ordered alphabetically. Therefore the items wouldn't necessarily appear in the list in the order that they were added from the recordset.

Don't know if that's the problem, but from the information available it's an idea.

Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Hi,

Thanks buddies. Let me explain.
My for has a list box with visibility set to false.
With it i create a feature that looks like a combobox on my datagrid. the code above is used use to programatically AddItems to the listbox.
Then...
Code:
Private Sub List1_DblClick()
    grdDataGrid.Columns(grdDataGrid.Col).Value = List1.List(List1.ListIndex)
    grdDataGrid.SetFocus
End Sub

Private Sub List1_LostFocus()
    List1.Visible = False
    grdDataGrid.SetFocus
End Sub
Here the focus leaves the listbox.
While i scroll down with the mouse - no prob.
But users will at times want to scroll with the keyboard arrows, this scrolls both the listbox and the Absoluteposition of the recordset also scrolls accordingly.

Please me understand why.

Paul
 
Friends, I am very new in using VB. Perhaps I left out something at some point, please dont assume.
Thanks in Advance
Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top