Results 1 to 5 of 5
  1. #1
    AKQTS is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2010
    Posts
    56

    Will not set focus

    I have the following code:
    Private Sub Append_Click()
    On Error GoTo Append_Click_Err



    DoCmd.RunCommand acCmdRefresh
    DoCmd.Echo True, ""
    DoCmd.SetWarnings False

    If Me.Job_Num.Enabled = True Then 'Check for a locked job
    Beep
    MsgBox "Lock The Job Please", vbCritical, "Lock Error"
    Else

    If DCount("*", "Pouch_Info") = 0 Then 'Check if serial number received
    Beep
    MsgBox "Serial number not active, please rescan or inform production supervisor.", vbCritical, "Scan Error"
    Else

    If DCount("*", "Job_Compare") = 0 And DCount("*", "Job_Compare_2") = 0 Then 'Check for already procesed under different job
    Beep
    MsgBox "Serial number processed under a different job, please rescan or inform production supervisor.", vbCritical, "Scan Error"
    Else

    If DCount("*", "Job_Compare") = 1 Then 'Check for reprint

    Call Reprint 'Call Reprint Private Sub

    Else
    DoCmd.OpenQuery "Pouch_Update", acViewNormal, acEdit 'Update Job Number
    Call Print_Pouch 'Call Print Pouch Private Sub
    Me.Ser_Num.SetFocus 'Set focus back to the serial number field

    End If
    End If
    End If
    End If

    Append_Click_Exit:
    Exit Sub
    Append_Click_Err:
    MsgBox "Call Andy at Extension 247", vbCritical, "ERROR"
    Resume Append_Click_Exit
    Exit Sub
    End Sub

    Private Sub Print_Pouch()

    DoCmd.OpenReport "Pouch_Label", acViewNormal, "", "", acHidden 'Open label report
    DoCmd.OpenQuery "Purge_After_Label", acViewNormal, acEdit 'Clear serial number in form
    DoCmd.SetWarnings True
    Me.Ser_Num.SetFocus 'Set focus back to the serial number field

    End Sub

    I cannot get the final set focus command in either code sets to work. When all is done, the form is highlighted in the navigation pane (off to the left side) of the access menu. The focus is not directly on the open form and then not set to the correct field.

    Any thoughts?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2007
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Not sure can be done, at least not finding any way with code. Closing the opened report and query objects will set focus back to the open form. Can also click on the form with the other objects open.

  3. #3
    AKQTS is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2010
    Posts
    56
    Form was not active after process had been ran. Made the form active, and set focus, worked flawlessly.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2007
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Could you post your solution? I tried to programmatically make the form active and was not succeeding. Am curious how you accomplished.

  5. #5
    AKQTS is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2010
    Posts
    56
    DoCmd.SelectObject acForm, "Box_Label", False
    DoCmd.RunCommand acCmdRefresh
    Me.Ser_Num.SetFocus 'Set focus back to the serial number field

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Text Get Focus
    By blueraincoat in forum Forms
    Replies: 4
    Last Post: 03-14-2011, 06:10 PM
  2. Set focus to a field on a subform
    By MiaAccess in forum Forms
    Replies: 11
    Last Post: 03-05-2011, 11:49 AM
  3. Passing focus to subform.....
    By smorelandii in forum Forms
    Replies: 3
    Last Post: 02-04-2011, 10:51 AM
  4. Set focus to another program
    By DrewB in forum Programming
    Replies: 1
    Last Post: 06-24-2009, 06:38 AM
  5. Keeping focus
    By ronatnc in forum Forms
    Replies: 0
    Last Post: 12-16-2008, 12:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums