Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.SetFocus ... can't make it work. 1

Status
Not open for further replies.

gusbrunston

Programmer
Feb 27, 2001
1,234
US
Hi:

After trapping an invalid entry, I'm trying to return the user to the appropriate control, like this:
[tt]
...
MsgBox msgString, 48, titleString
DoCmd.CancelEvent 'tried omitting this
Me!cboPayerPayee.Undo 'tried omitting this
Me.cboPayerPayee.SetFocus
...[/tt]

However, after closing the msg box the focus goes to the next control in the tab order (tab view).

Appreciate any help with this. [glasses] Gus Brunston, using Access2000 Intermediate skills.
 
Hi Gus!

In the control's BeforeUpdate event use the following code:

If YourValidation = False Then
MsgBox msgString, 48, titleString
Cancel = -1
End If

This will stop the update and automatically retain the focus in the original control.

hth
Jeff Bridgham
bridgham@purdue.edu
 
I had this one too. Ended up first setting the focus to another control & then to the control I wanted!
ie
Code:
Me!cboPayerPayee.Undo
 Me.cboOther.SetFocus
   Me.cboPayerPayee.SetFocus
 
[tt]
Works like a charm! Thanks very much.

Wonder why I can't find answers in those big thick books?

Happy holiday season. [glasses] Gus Brunston, using Access2000 Intermediate skills.
 
[tt]
Dear Jeff:
My comment was intended for you. Hence, the star.

Dear Sha76:
Thanks for your response to my thread. That looks like a good work around.

Cheers to both of you. [glasses] Gus Brunston, using Access2000 Intermediate skills.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top