TextBox AfterUpdate Focus

M

Michael

Hi Folks - In version 2003, if I enter an account# in a textbox and press
the Enter key, the following code runs and the focus is returned to the
textbox:

Private Sub Combo202_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Form_frmReviews.RecordsetClone
rs.MoveFirst
rs.FindNext "[medrecno] = '" & Me![Combo202] & "'"
If Not rs.NoMatch Then
Form_frmReviews.Bookmark = rs.Bookmark

Else
Me.lblCaseNotFound.Visible = True


End If
Me.cmdFindNext.Enabled = True
Me.Combo202.SetFocus

End Sub

-----

In version 2000, if I enter an account# in a textbox and press the Enter
key, the following code runs and the focus is sent to the NEXT field.

Is there a property change I can make to keep the focus on the original
textbox after the update? Thanks.

Michael
 
J

Jeff Boyce

Michael

A bit of confusion here, maybe just a terminology issue...


"if I enter an account# in a textbox" ... but your code mentions
"Combo202_AfterUpdate". Are you working with a textbox or a combobox?

And if you do have a combobox that lists all the possible items, why do you
need to test to see if you found one that you just got from the combobox?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
M

Michael

Jeff - My mistake ... It was originally a combo box, but the user did not
want the drop-down functionality, so I converted the combo box to a text box
but did not change the name. They want to enter an account number in a
textbox, then press Enter to find the account number. Make sense?

Michael




Jeff Boyce said:
Michael

A bit of confusion here, maybe just a terminology issue...


"if I enter an account# in a textbox" ... but your code mentions
"Combo202_AfterUpdate". Are you working with a textbox or a combobox?

And if you do have a combobox that lists all the possible items, why do
you need to test to see if you found one that you just got from the
combobox?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Michael said:
Hi Folks - In version 2003, if I enter an account# in a textbox and press
the Enter key, the following code runs and the focus is returned to the
textbox:

Private Sub Combo202_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Form_frmReviews.RecordsetClone
rs.MoveFirst
rs.FindNext "[medrecno] = '" & Me![Combo202] & "'"
If Not rs.NoMatch Then
Form_frmReviews.Bookmark = rs.Bookmark

Else
Me.lblCaseNotFound.Visible = True


End If
Me.cmdFindNext.Enabled = True
Me.Combo202.SetFocus

End Sub

-----

In version 2000, if I enter an account# in a textbox and press the Enter
key, the following code runs and the focus is sent to the NEXT field.

Is there a property change I can make to keep the focus on the original
textbox after the update? Thanks.

Michael
 
J

Jeff Boyce

Michael

So why do you want the focus to go back to the textbox if you DO find a
match? I could see going back there if there was no match, but ...?

Your users must be highly confident that they'll remember and correctly
enter AccountNumbers. Most folks don't/can't.

As a compromise, what about the idea of having a combobox that lets them
start typing the AccountNumber and finds the first one with the "number(s)"
typed so far ...? Type 2 numbers, see the Account Numbers that start with
those two. Type 3, ... ... and type a combination that doesn't exist, the
list disappears, a visual indicator.

You can do this by setting the property for the combobox that governs
auto-completion.

Regards

Jeff Boyce
Microsoft Office/Access MVP


Michael said:
Jeff - My mistake ... It was originally a combo box, but the user did not
want the drop-down functionality, so I converted the combo box to a text
box but did not change the name. They want to enter an account number in a
textbox, then press Enter to find the account number. Make sense?

Michael




Jeff Boyce said:
Michael

A bit of confusion here, maybe just a terminology issue...


"if I enter an account# in a textbox" ... but your code mentions
"Combo202_AfterUpdate". Are you working with a textbox or a combobox?

And if you do have a combobox that lists all the possible items, why do
you need to test to see if you found one that you just got from the
combobox?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Michael said:
Hi Folks - In version 2003, if I enter an account# in a textbox and
press the Enter key, the following code runs and the focus is returned
to the textbox:

Private Sub Combo202_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Form_frmReviews.RecordsetClone
rs.MoveFirst
rs.FindNext "[medrecno] = '" & Me![Combo202] & "'"
If Not rs.NoMatch Then
Form_frmReviews.Bookmark = rs.Bookmark

Else
Me.lblCaseNotFound.Visible = True


End If
Me.cmdFindNext.Enabled = True
Me.Combo202.SetFocus

End Sub

-----

In version 2000, if I enter an account# in a textbox and press the Enter
key, the following code runs and the focus is sent to the NEXT field.

Is there a property change I can make to keep the focus on the original
textbox after the update? Thanks.

Michael
 

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

Top