Results 1 to 3 of 3
  1. #1
    Join Date
    May 2003
    Location
    Providence, RI
    Posts
    12

    Unanswered: SetFocus on Lost Focus

    Hi all. Here's my plan - when a user skips over a field in a form, the script should pop up an error message and then return the focus to the control that was skipped. I tried:

    Private Sub CompanyAgency_LostFocus()
    Dim NameNull
    If IsNull(Forms!Contacts!CompanyAgency) Then
    NameNull = MsgBox("Please Enter the Company or Agency Name", vbOKOnly, Error)
    Me!CompanyAgency.SetFocus
    End If
    End Sub

    but the focus will only stay in the control for a fraction of a second, and then move on to wherever the focus was when the event was first called. Any ideas? The code works fine if I set the focus to a control other than the one that the event is linked to, but that doesn't help me.

    Thanks,

    EdM

  2. #2
    Join Date
    Feb 2003
    Location
    Auckland, NZ
    Posts
    150
    Try the On Exit Event rather than On Lost Focus
    JJ Kennedy
    Double J IT Solutions
    www.doublejit.co.nz

    VB 6, VB.NET, ASP.NET, MS SQL Server, MySQL, MS Access

  3. #3
    Join Date
    May 2003
    Location
    Providence, RI
    Posts
    12

    Angry Hmmm.

    Thanks for the reply. Unfortunately, I completed hosed the whole database shortly after I posted (don't know how - if I did, I'd be much happier) and I'm in the process of rebuilding it. Once I get to that part again, I'll give your suggestion a try.

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •