UserForm

shallnotbe

New Member
Joined
Oct 27, 2022
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Good afternoon, I have a userform that has some textboxes and command buttons. one of the text boxes is used to scan a bar code and log in in a field. When it is done i need it to clear and put the focus back on the box. I have accomplished this by doing this code at the end of the exit sub. The problem is, i cannot use the command buttons when this code is present. it won't give up focus of the textbox in order to click on the command button. What is a better way to do this? I hope I am clear.

If CCP_TextBox.Value = "" Then
CCP_TextBox.SetFocus
Cancel = True
End If
Thank you
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
I think I got it working. I checked in the beginning if it was empty and exit sub if it is. This allowed me to use the button. Can't say I understand it completely, but it is doing what I need now.
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,850
Members
449,051
Latest member
excelquestion515

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