Results 1 to 7 of 7

Thread: Select A Textbox
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    May 2018
    Posts
    103
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Select A Textbox

    Hi,

    I have a data entry text box in a form called Issue_or_Turnover. I am running a macro that opens an append query based on the text inputted into box Work_Order. At the end of the macro I want the cursor to go back to text box Work_Order.

    I have tried many different versions of the setfocus command. Many tries with Docmd.SelectObject but nothing has worked. Ideas?

  2. #2
    Board Regular My Aswer Is This's Avatar
    Join Date
    Jul 2014
    Posts
    15,805
    Post Thanks / Like
    Mentioned
    28 Post(s)
    Tagged
    13 Thread(s)

    Default Re: Select A Textbox

    Have you tried this:
    TextBox1.SetFocus
    Be sure and always test this script on sample data the first time you use this as to avoid any problems with your data. Always trying to learn more and help others where I can. I'm using Excel 2013.
    Patience please Iím not perfect yet. "Memories are forever"

  3. #3
    Board Regular
    Join Date
    May 2018
    Posts
    103
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Select A Textbox

    Quote Originally Posted by My Aswer Is This View Post
    Have you tried this:
    TextBox1.SetFocus
    Yes. Unfortunately, the set focus doesn't seem to go back to the box. It's unbound and I changed the name but SetFocus doesn't seem to work.

    It gives an "object required" error. Here's my code:

    Code:
    Issue_To_Floor_Work_Order.SetFocus
    Last edited by Pestomania; Jun 28th, 2019 at 02:09 PM.

  4. #4
    Board Regular JonXL's Avatar
    Join Date
    Feb 2018
    Posts
    213
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Select A Textbox

    Is this part of a With statement? If not, you also need to reference the form, eg, with Me:

    Code:
     Me.Issue_To_Floor_Work_Order.SetFocus

  5. #5
    Board Regular
    Join Date
    May 2018
    Posts
    103
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Select A Textbox

    Quote Originally Posted by JonXL View Post
    Is this part of a With statement? If not, you also need to reference the form, eg, with Me:

    Code:
     Me.Issue_To_Floor_Work_Order.SetFocus
    It is not part of a With statement. And I have tried the ME statements but it states that it's an invalid use of the property.

    Hmm. Not easy to type all of the code on my phone, but I'll see if I can Monday.

  6. #6
    Board Regular
    Join Date
    Jun 2015
    Location
    Ontario, Canada
    Posts
    1,698
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Select A Textbox

    Is there a naming problem here?
    I want the cursor to go back to text box Work_Order.
    Probably not, as
    Issue_To_Floor_Work_Order is the actual name, I suppose. If the control is disabled or locked you can't set focus to it.

    Not being much of a macro user, I'll ask - doesn't the macro builder provide the ability to navigate to the proper form/control by displaying these objects in drop-downs (combos) so that you don't get such error messages?
    Tips for posting problems:
    1) "doesn't work" doesn't help. Post error message text/numbers and/or state what's happening.
    2) if posting code or sql, use code tags; specify on which code line errors occur, if applicable
    3) try to be specific; assume we know nothing about your issue - because we don't!

    Make all suggested changes in copies of your database or to its objects.

    "1 out of 1010 people understand binary. The other 1001 don't."

  7. #7
    Board Regular
    Join Date
    May 2013
    Posts
    644
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Select A Textbox

    I think the O/P means VBA when they say Macro, as in Excel macro.
    If it was an Access macro they would use the GoToControl action. However it does not supply control names, you have to type them in with no intellisense available.
    Office 2007
    Access novice. Sometimes trying to give something back

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •