Fordraiders
asked on
Remember index place in userform listbox
I have a Useform(model) that contains a listbox.
I'm hiding the form and then reshowing the form modelessly.
When I do this I lose my place in the listbox index ?
Is there a way to go back to the same place in the listobx before I hide the userform ?
Thanks
fordraiders
I'm hiding the form and then reshowing the form modelessly.
When I do this I lose my place in the listbox index ?
Is there a way to go back to the same place in the listobx before I hide the userform ?
Thanks
fordraiders
Private Sub CommandButton8_Click()
'
Me.Hide
Me.Show vbModeless
'
With frmList
.Height = 225
.Top = Application.Top + 350
.Left = Application.Left + 25
End With
End Sub
I can't replicate that. Any code in the form's activate event?
ASKER
well, here is what I did. Since hiding the form will kill
public variables...
I created textfile to hold the index number and write it to a FreeFile.
Then when the form is unhidden...tell the listbox to go to the listindex number from the freefile.
Public sidx as integer
sidx = Me.ListBox1.ListIndex
after re-opening the freefile
' ok we should have it and find correct index
ListBox1.SetFocus
With frmList
With ListBox1
.Selected(sidx) = True
End With
End With
public variables...
I created textfile to hold the index number and write it to a FreeFile.
Then when the form is unhidden...tell the listbox to go to the listindex number from the freefile.
Public sidx as integer
sidx = Me.ListBox1.ListIndex
after re-opening the freefile
' ok we should have it and find correct index
ListBox1.SetFocus
With frmList
With ListBox1
.Selected(sidx) = True
End With
End With
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry , I think its the refreshing of the listbox data ?
Nope that shouldn't do it either.
ASKER
ok sorry its the error handling that deleting the variables.
I put in proper error control and now at least don't lose the variable
created a public variable
i = listbox1.listindex
and when the form unhides..just set the list box to the saved index holder.
I put in proper error control and now at least don't lose the variable
created a public variable
i = listbox1.listindex
and when the form unhides..just set the list box to the saved index holder.
ASKER
Thanks