How to keep textbox in focus while also inputting data into table

ManIdk

New Member
Joined
Apr 25, 2022
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hey guys, I'm meddling in VBA, having lots of fun but I'm running into issues.

I'm attempting to use a barcode scanner to scan multiple items into a table. I've gotten everything to input where it should, but when I hit enter (scan button) it goes to the command button automatically. I have dozens of barcodes to scan, so it would be a hassle to have to walk over to my computer and press enter each time. I'm wondering if I can set it to either click "Submit" immediately once I scan something or if I can just have it set focus to my textbox at all times. Please let me know if there's more context needed. Code below

VBA Code:
Private Sub cmbSubmit_Click()

    Dim LastRow As Long
    LastRow = Cells(Rows.Count, 14).End(xlUp).Row
    Cells(LastRow + 1, 14).Value = Me.tbxSN1
    Me.tbxSN1.Value = ""
    Cells(LastRow + 1, 13).Value = Me.cbxTechID
    Cells(LastRow + 1, 16).Value = Me.tbxDate

End Sub

Private Sub cmbClose_Click()

Unload Me

End Sub



Private Sub UserForm_Initialize()
   
    Me.cbxTechID.RowSource = "'Information'!A2:A10"
    
End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Update:

I figured it out. The solution using BeforeUpdate, keeping the same code, and adding "Cancel = True"
I'm going to bed.
 
Upvote 0

Forum statistics

Threads
1,214,968
Messages
6,122,506
Members
449,089
Latest member
RandomExceller01

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