I have a form for stock taking, basically recording all samples at different locations. The form consists of simply a combobox for Location and a textbox for Sample number.
I would like to keep the selected option of location while scanning sample barcodes.
By running the below codes, I end up with my combobox entry highlighted and have to manually press the tab key to go to the textbox for next data entry. Seems simply writing txtSample.SetFocus does not work. Is there a way to keep the value of a combobox and set focus to the next textbox?
Private Sub cboLocation_Change()
txtSample.SetFocus
SelectedLocation = Me.cboLocation.Text
End Sub
Private Sub txtSample_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = vbKeyReturn Then
RecordSample
txtSample = ""
cboLocation = SelectedLocation
txtSample.SetFocus
End If
End Sub
user25097612 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.