Results 1 to 3 of 3
  1. #1
    rameshjctr is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2016
    Posts
    16

    tab not working in my dataentry form


    friends,
    I have coded in my textbox's lostfocus event to check whether a particular entry already exists in the table. it gives correct result but when u click the ok button, it doesnt get tab focused in the first textbox. instead it focuses on second textbox which is meant for password. the code is given below:

    Private Sub Text1_LostFocus()
    Dim uname As String

    uname = Me!Text1
    If uname = DLookup("[PEN]", "USERS", "[PEN]=" & Me!Text1.Value) Then
    Me!Text1 = ""
    Me!Text1.SetFocus
    MsgBox ("USER ALREADY EXISTS")
    Else
    End If

    End Sub

    can anyone help correct this.

    thanking you in advance

    ramesh

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Have you tried:
    Code:
    Private Sub Text1_LostFocus()
    Dim uname As String
    
     uname = Me!Text1
     If uname = DLookup("[PEN]", "USERS", "[PEN]=" & Me!Text1.Value) Then
      MsgBox ("USER ALREADY EXISTS")
      Me!Text1 = ""
      Me!Text1.SetFocus
     Else
     End If
    
    End Sub
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    rameshjctr is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2016
    Posts
    16
    tried. trying now also to find a way out.
    i tried by pressing tab, then enter both results in same. the focus never sets in text1 where i have to enter userid
    i think the pressing of tab or enter key gets registered somewhere.....
    initially i thought after if..then only one of the statement is working, so i put a lonely else to overcome that. but still in vain.

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

Similar Threads

  1. Replies: 3
    Last Post: 12-19-2014, 12:06 PM
  2. BrowseTo and DataEntry on navigation form
    By Daimios in forum Forms
    Replies: 3
    Last Post: 06-05-2014, 07:31 AM
  3. Replies: 1
    Last Post: 01-20-2012, 03:09 PM
  4. Replies: 2
    Last Post: 08-01-2011, 11:35 PM
  5. Replies: 9
    Last Post: 09-25-2010, 10:14 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