Results 1 to 2 of 2
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    2,097

    String Variable substitution for SetFocus


    If one has a text box named "tbMyTextBox", one would write Me.tbMyTextBox.SetFocus to set the focus to that text box. However, If the name of the text box happens to be stored in a string variable, say strMyTextBoxName, what's the syntax of the SetFocus statement using strMyTextBoxName?

  2. #2
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    2,097
    AH! I put the name of the string in quotes when referencing the controls collection, Me.Controls("strMyTextBoxName").SetFocus. Simple enough of a mistake so I don't know how I missed that to the extent that I bothered to post here.

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

Similar Threads

  1. Using Variable String to Set a Form object
    By neo651 in forum Programming
    Replies: 17
    Last Post: 07-08-2013, 12:59 PM
  2. Replies: 3
    Last Post: 05-28-2013, 12:53 PM
  3. Extract Value from Variable in String
    By nguyenak in forum Programming
    Replies: 3
    Last Post: 05-24-2012, 03:50 PM
  4. Variable substitution problem.
    By bsc in forum Programming
    Replies: 2
    Last Post: 01-11-2012, 09:33 AM
  5. Using a string variable to specify a control
    By Gerry in forum Programming
    Replies: 3
    Last Post: 04-14-2010, 02:28 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