controlling the focus of a textbox

EDUCATED MONKEY

Board Regular
Joined
Jul 17, 2011
Messages
218
Hello all my set up office 2007 win xp pro IE 8
Can anyone suggest away to toggle between two textboxes by the click of a command button at present I have a clear command button the clears the textbox should the wrong code be scanned and set the focus of the textbox
Rich (BB code):
Private Sub BtnClear_Click()
TextBoxIsbn.Value = ""
TextBoxIsbn.SetFocus
End Sub
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
The aim is to take the input from a barcode reader; the difficulty is that barcodes are of different lengths in my case 13 or 10 digits, at the moment I use the code below to detect 13 digits so I was hoping to set up a similar situation with a 10 digit textbox
<o:p></o:p>
Rich (BB code):
Private Sub TextBoxIsbn_Change()
Dim MyData As Variant
If Len(TextBoxIsbn.Value) = 13 Then
MyData = TextBoxIsbn.Value
Module11.SaveData (MyData)    ‘ all this does is find the next available row in a particular worksheet
End If
End Sub
 
Last edited:

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,215,327
Messages
6,124,294
Members
449,149
Latest member
mwdbActuary

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