AccessTr.neT
Comboboxda İtem Ve İndexe Göre Seçim Yapmak - Baskı Önizleme

+- AccessTr.neT (https://accesstr.net)
+-- Forum: Microsoft Access (https://accesstr.net/forum-microsoft-access.html)
+--- Forum: Access Örnekleri ve Uygulamaları (https://accesstr.net/forum-access-ornekleri-ve-uygulamalari.html)
+--- Konu Başlığı: Comboboxda İtem Ve İndexe Göre Seçim Yapmak (/konu-comboboxda-item-ve-indexe-gore-secim-yapmak.html)



Comboboxda İtem Ve İndexe Göre Seçim Yapmak - accessman - 03/05/2020

Kod:
Public Sub SelectComboBoxItemByText(cmb As ComboBox, Value As String)
    On Error GoTo ErrHandler_
Dim i As Integer
    For i = 0 To cmb.ListCount - 1
        If cmb.Column(1, i) = Value Then
            cmb.SetFocus
            cmb.Selected(i) = True
            cmb.Text = Value
            Exit For
        End If
    Next i
End Sub
ExitProc_:
    DoCmd.Hourglass False
    Exit Sub
ErrHandler_:
    DoCmd.Hourglass False
    Call LogError(Err, "basTools", "SelectComboBoxItemByText")
    Resume ExitProc_
    Resume ' use for debugging
End Sub

Kod:
Public Sub SelectComboBoxItemById(cmb As ComboBox, Value As Integer)
    On Error GoTo ErrHandler_
Dim i As Integer
    For i = 0 To cmb.ListCount - 1
        If cmb.Column(0, i) = Value Then
            cmb.SetFocus
            cmb.Selected(i) = True
            cmb = Value
            Exit For
        End If
    Next i
ExitProc_:
    DoCmd.Hourglass False
    Exit Sub
ErrHandler_:
    DoCmd.Hourglass False
    Call LogError(Err, "basTools", "SelectComboBoxItemById")
    Resume ExitProc_
    Resume ' use for debugging
End Sub