R
RipperT
Hi, The following code allows the user to search for a record using a combo
box. If the record is not found, the message appears. When the user clicks
OK, I would like the fields contents to remain selected, ready to accept the
next entry. This code is not doing it in the after_update event. The combo
box field retains focus, but the text is not highlighted - just a cursor in
front of the text. I have also tried using SetFocus to set the focus to
different field, then set it back to the combo box, but that doesn't work
either. Can anyone help? Many thanx. (Access 2002)
Private Sub Combo206_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[InmateId] = '" & Me![Combo206] & "'"
If rs.NoMatch Then
MsgBox "The inmate number you entered is not in the database."
Else
Me.Bookmark = rs.Bookmark
End If
Forms!frmInmates!Combo206.SetFocus
With Combo206
.SelStart = 0
.SelLength = Len(Combo206)
End With
End Sub
box. If the record is not found, the message appears. When the user clicks
OK, I would like the fields contents to remain selected, ready to accept the
next entry. This code is not doing it in the after_update event. The combo
box field retains focus, but the text is not highlighted - just a cursor in
front of the text. I have also tried using SetFocus to set the focus to
different field, then set it back to the combo box, but that doesn't work
either. Can anyone help? Many thanx. (Access 2002)
Private Sub Combo206_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[InmateId] = '" & Me![Combo206] & "'"
If rs.NoMatch Then
MsgBox "The inmate number you entered is not in the database."
Else
Me.Bookmark = rs.Bookmark
End If
Forms!frmInmates!Combo206.SetFocus
With Combo206
.SelStart = 0
.SelLength = Len(Combo206)
End With
End Sub