Select A Textbox

Pestomania

Active Member
Joined
May 30, 2018
Messages
332
Office Version
  1. 365
Platform
  1. Windows
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?
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
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:
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
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?
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top