Problem with setFocus

A

Andy Dorph

The following is a code snippet:

If txtAmount > txtOrigAmt Then
MsgBox ("You may not pay more than the obligation amount.")
txtAmount.Value = txtOrigAmt.Value
txtAmount.SetFocus
Else . . .
End If

When the code executes, the cursor goes to the next field (tab order)
instead of the txtAmount field. How can I fix this?

Thanks
 
R

Rick B

Where is this code?

you most likely execute this code before the focus moves to the next field
(before update) so the code is executed (including setting the focus) then
Access moves to the next field.

Replace your setfocus command or add a line right after it like...

Cancel = True


Please note: If you had searched, this same question was answered at least
once in the last week or two.

Rick B
 

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