Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2007
    Posts
    214

    Unanswered: Form setfocus issue

    I have a search on my form where if the record is not fount, I want the social security field on that form to have focus so I can begin entering the new record. However, I've tried every setfocus combination I can, and after the search, the form freezes briefly and the social security field will not get focus. Below is my code. Is there any sure way to get focus on the social security field after no records are found?


    If Not IsNull(Me!FSS) Then
    Me.RecordSource = "Select * from [Claim Tracking System] where [Social Security] = '" & Forms![Claims Tracking System]!FSS & "'"

    Me.OrderBy = "Last Updated desc"
    Me.OrderByOn = True


    If Me.RecordsetClone.recordcount = 0 Then

    MsgBox "No records meet the criteria. Please try again.", vbOKOnly




    Me.Social_Security.SetFocus












    End If

    End If

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    In which event do you run that code?
    Have a nice day!

  3. #3
    Join Date
    Oct 2007
    Posts
    214
    It is in the afterupdate event. Thanks.

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    I cannot reproduce the behaviour you describe. When I try a similar process everything works as expected. However, here's a workaround:
    Code:
    Private Sub CLIENT_AfterUpdate()
    
        If Not IsNull(Me!FSS) Then
            Me.RecordSource = "Select * from [Claim Tracking System] where [Social Security] = '" & Forms![Claims Tracking System]!FSS & "'"
            Me.OrderBy = "Last Updated desc"
            Me.OrderByOn = True
            If Me.RecordsetClone.RecordCount = 0 Then
                MsgBox "No records meet the criteria. Please try again.", vbOKOnly
                Me.TimerInterval = 2
            End If
        End If
    
    End Sub
    
    Private Sub Form_Timer()
    
        Me.TimerInterval = 0
        Me.CLIENT.SetFocus
        
    End Sub
    Have a nice day!

  5. #5
    Join Date
    Oct 2007
    Posts
    214
    I tried the above code with no avail. Maybe this will help. As the search is being executed, the access front end briefly displays a "not responding" message, then once the search is complete, focus is NOT where it needs to be...I'm thinking this is because of the not responding issue. Any suggestions based on this? 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
  •