Results 1 to 2 of 2
  1. #1
    MFeightner is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2009
    Posts
    3

    Question Setting Focus on a Form

    I am having trouble setting the focus on my form after a test for correct information. Is what I have so far:
    Dim varX
    varX = DLookup("[PersonAssigned]", "Passwords", "[Password] = Forms![Label-Creation]![Password]")
    If IsNull(varX) Then
    MsgBox "The password you entered is not valid for this operation"
    Me!Password = ""


    Me!Creator = ""
    Me!Password.SetFocus
    Else
    Me.Creator = varX
    Me.Creator.Requery
    End If
    It is suppose to go lookup the person assigned that the password entered and validate if they are able to this operation. It does everything except if it fails the test it goes to the next field on the form rather than back to the password text box.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Validation code should be placed in the BeforeUpdate event of a control. That event can be cancelled which holds the focus in the control. Where did you put the code you posted?

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

Similar Threads

  1. Set focus to another program
    By DrewB in forum Programming
    Replies: 1
    Last Post: 06-24-2009, 06:38 AM
  2. Replies: 2
    Last Post: 03-10-2009, 05:14 PM
  3. Keeping focus
    By ronatnc in forum Forms
    Replies: 0
    Last Post: 12-16-2008, 12:32 AM
  4. problem setting Excel sheet name in vba from a form
    By dataman in forum Programming
    Replies: 2
    Last Post: 04-18-2006, 07:26 AM
  5. Replies: 1
    Last Post: 12-21-2005, 12:27 AM

Tags for this Thread

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