03/05/2020, 09:51
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