Unable to type in a userform textbox with a SetFocus

slave1spectre

New Member
Joined
Nov 4, 2019
Messages
11
Hi All,

Hopefully this is a simple fix but the problem I'm having is that I have a textbox on a userform that is used as the intake for a value. I added some preset brackets with a SetFocus to the textbox so that when the user enters a value and adds it to the spreadsheet the program will auto-populate the brackets around the value. I've tried setting the tb to either "After Update", "Change", and "Enter" but the only one that will display the brackets properly and with the correct SetFocus within the tb is the "Change". The only problem I am having now is that when I run the macro and try entering data into that tb the cursor will be in the right place but I'm unable to type anything into the tb. This seems pretty straight forward so what am I missing?

VBA Code:
Private Sub tbNEWBARCODE_Change()
tbNEWBARCODE.Value = "{}"
tbNEWBARCODE.SelStart = 1
End Sub
 

Attachments

  • 2019-12-03_10-18-30.jpg
    2019-12-03_10-18-30.jpg
    4.7 KB · Views: 1

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Why don't you just add the brackets to the text when you write it to the worksheet?
 
Upvote 0
Because the values that are being populated into the cell are scanned barcodes. It would take way to long to have to manually add the brackets during the scanning process.
 
Upvote 0
I didn't suggest doing it manually. How are you getting the values into the worksheet?
 
Upvote 0
Multi-funtion userform that is used for fast testing verification, adding a new asset, and marking damaged assets. The only thing giving me issue is this tb when adding an asset to the spreadsheet.
 
Upvote 0
That doesn't answer my question. How do the values get from the textbox to the worksheet?
 
Upvote 0
This portion of the form is made up of multiple textboxes, comboboxes, and a date picker. Everything is added via a command button.
 
Upvote 0
cb code is...
VBA Code:
Private Sub cbADDNEWASSET_Click()
If Range("E3") <> "" Then
Rows("3:3").Select
Selection.Insert Shift:=xlDown
End If

If Range("B3") = "" Then
Range("E3") = tbNEWBARCODE.Text
Range("F3") = tbNEWSTAMPEDTAG.Text
Range("G3") = NEWDATEPICKER.Value
Range("H3") = cbNEWAPPTYPE.Value
Range("I3") = cbNEWAPPCOLOR.Value
Range("J3") = cbNEWAPPPATTERN.Value
Range("K3") = tbNEWSECCOLOR.Text
Range("L3") = tbNEWDROWNER.Text
Range("M3") = cbNEWSITE.Value
Range("N3") = cbNEWDEPT.Value
Range("O3") = tbNEWLOCDEETS.Text
End If

tbNEWBARCODE.Text = ""
tbNEWSTAMPEDTAG.Text = ""
cbNEWAPPTYPE.Value = ""
cbNEWAPPCOLOR.Value = ""
cbNEWAPPPATTERN.Value = ""
tbNEWSECCOLOR.Text = ""
tbNEWDROWNER.Text = ""
cbNEWSITE.Value = ""
cbNEWDEPT.Value = ""
tbNEWLOCDEETS.Text = ""
Range("A3").Select
End Sub
 
Upvote 0
So instead of:

Code:
Range("E3") = tbNEWBARCODE.Text

use:

Code:
Range("E3") = "{" & tbNEWBARCODE.Text & "}"
 
Upvote 0
Aww man I was so close with one of my previous attempts! ? Your suggestion worked like a charm; much appreciated brother! ?
 
Upvote 0

Forum statistics

Threads
1,214,787
Messages
6,121,558
Members
449,038
Latest member
Guest1337

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