Set focus problem

R

RipperT

Hello,
I have a combo box that users can use to look up a field value in the
database. If the value is not found, a message box appears saying as much
with an OK button. When the user clicks OK, either with the mouse or the
Enter key, I would like the focus on the same combo box with the previously
typed value highlighted, ready for the next entry. I am using:

Forms!myForm!Combo206.SetFocus

which sets the focus, but the text is not highlighted; the cursor is at the
beginning of the field. Is there a way to get the field highlighted?

Many thanx,

Rip
 
G

Guest

Try the following:
with cbobox
.selstart=0
.sellength=len(cbobox)
end with

Hope this helps!
 
R

RipperT

It's not working. Am I using it correctly?

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

Many thanx,

Ripper
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

text field value remain selected 3
Change Tab Without changing focus 1
set focus on combo box 1
Lost Focus Woes 7
List Box 1
Code working in 2K3, but not 2K7 4
SetFocus Problems 2
Focus set to subform control 1

Top