Results 1 to 6 of 6
  1. #1
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398

    if then statement to check for location of focus


    What is the correct syntax for a if - then statement to determine if a specific text box has the focus? Thanks!!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    See if the ActiveControl property does what you need.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    I found screen.previouscontrol, but I can't figure out the syntax for the if/then statement. Here's what I have, a textbox named "individual", I have a button that the user is able to click on, on the click, I need to determine if the screen.previouscontrol was me.individual. This is what I've tried, if screen.previouscontrol = me.individual then. But this does not work.

  4. #4
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    I figured it out.
    if screen.previouscontrol.name = "individual" then

    Thanks for your help!!

  5. #5
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    In VBA help they do this:

    Dim ctlPrevious As Control

    Set ctlPrevious = Screen.PreviousControl
    If ctlPrevious.Name = "txtFinalEntry" Then
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Access VBA statement to check for Null entries
    By tim_tims33 in forum Access
    Replies: 4
    Last Post: 01-24-2012, 12:19 PM
  2. Warehouse location adjustment
    By tj63069 in forum Database Design
    Replies: 5
    Last Post: 01-11-2012, 06:19 PM
  3. Check my Select Statement in Form
    By OMGsh Y did I say Yes in forum Forms
    Replies: 12
    Last Post: 12-07-2010, 02:13 PM
  4. File Location
    By Mitch87 in forum Programming
    Replies: 1
    Last Post: 02-19-2010, 11:12 AM
  5. OpenReport Command with Double Check Where Statement
    By Robert M in forum Programming
    Replies: 3
    Last Post: 09-17-2009, 04:01 PM

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