D
David C. Holley
I'm a big fan of supplying users with a means to select a value in a list
box by manually entering it since it gives them a better overall experience.
The code below was copied as-is from a form that has an unbound text box and
an unbound list box. When the value is entered in the text box, it
successfully sets the value of the list box and selects the appropriate item
in the list box. However, I've copied it as-is to a new form and while I've
changed the form & control names appropriately, its not friggin' selecting
the item in the list box.
I have confirmed that the .BoundColumn property of the new list box is set
to the relevant field in the record source.
Private Sub pg1_txtTrailerNumberSearch_AfterUpdate()
On Error GoTo Err_pg1_txtTrailerNumberSearch_AfterUpdate
[Forms]![frmTrailerInventoryMaintenance]![pg1_lstTrailerInventory] =
[Forms]![frmTrailerInventoryMaintenance]![pg1_txtTrailerNumberSearch]
If
[Forms]![frmTrailerInventoryMaintenance]![pg1_lstTrailerInventory].ItemsSelected.Count
= 0 Then
MsgBox "Trailer number not found.", vbInformation + vbOKOnly
End If
Exit_pg1_txtTrailerNumberSearch_AfterUpdate:
Exit Sub
Err_pg1_txtTrailerNumberSearch_AfterUpdate:
MsgBox getDefaultErrorMessage(Me.Name,
"pg1_txtTrailerNumberSearch_AfterUpdate", Err.Number), vbCritical
Resume Exit_pg1_txtTrailerNumberSearch_AfterUpdate
End Sub
box by manually entering it since it gives them a better overall experience.
The code below was copied as-is from a form that has an unbound text box and
an unbound list box. When the value is entered in the text box, it
successfully sets the value of the list box and selects the appropriate item
in the list box. However, I've copied it as-is to a new form and while I've
changed the form & control names appropriately, its not friggin' selecting
the item in the list box.
I have confirmed that the .BoundColumn property of the new list box is set
to the relevant field in the record source.
Private Sub pg1_txtTrailerNumberSearch_AfterUpdate()
On Error GoTo Err_pg1_txtTrailerNumberSearch_AfterUpdate
[Forms]![frmTrailerInventoryMaintenance]![pg1_lstTrailerInventory] =
[Forms]![frmTrailerInventoryMaintenance]![pg1_txtTrailerNumberSearch]
If
[Forms]![frmTrailerInventoryMaintenance]![pg1_lstTrailerInventory].ItemsSelected.Count
= 0 Then
MsgBox "Trailer number not found.", vbInformation + vbOKOnly
End If
Exit_pg1_txtTrailerNumberSearch_AfterUpdate:
Exit Sub
Err_pg1_txtTrailerNumberSearch_AfterUpdate:
MsgBox getDefaultErrorMessage(Me.Name,
"pg1_txtTrailerNumberSearch_AfterUpdate", Err.Number), vbCritical
Resume Exit_pg1_txtTrailerNumberSearch_AfterUpdate
End Sub