tiger51's avatar
tiger51
Copper Contributor
Apr 02, 2025
Status:
Declined

access vba topindex example fail

listindex works topindex seems removed

and focus was needed to add if text value not need focus

not clear where initialize come from and how to use

Private Sub CommandButton1_Click() 
 ListBox1.TopIndex = ListBox1.ListIndex 
 TextBox1.Text = ListBox1.TopIndex 
 TextBox2.Text = ListBox1.ListIndex 
End Sub 
 
Private Sub ListBox1_Change() 
 TextBox1.Text = ListBox1.TopIndex 
 TextBox2.Text = ListBox1.ListIndex 
End Sub 
 
Private Sub UserForm_Initialize() 
 Dim i As Integer 
 
 For i = 0 To 24 
 ListBox1.AddItem "Choice " & (i + 1) 
 Next i 
 ListBox1.Height = 66 
 CommandButton1.Caption = "Move to top of list" 
 CommandButton1.AutoSize = True 
 CommandButton1.TakeFocusOnClick = False 
 
 Label1.Caption = "Index of top item" 
 TextBox1.Text = ListBox1.TopIndex 
 
 Label2. Caption = "Index of current item" 
 Label2.AutoSize = True 
 Label2.WordWrap = False 
 TextBox2.Text = ListBox1.ListIndex 
End Sub

2 Comments

Comments have been turned off for this idea
  • Allen's avatar
    Allen
    Icon for Community Manager rankCommunity Manager
    Status changed:
    New
    to
    Declined

    This space is for ideas about the Microsoft Tech Community, for ideas about access please visit the Microsoft Feedback Hub