I am using Access 2000 and read somewhere that my problem might be a quirk.
I need to have the focus return to the textbox, txtBar, in the code below. The focus always goes to the next field in the tab order of the form. I've changed the tab order and it always goes to the next command button or text field in the tab order. It is currently tabbing to txtLastScan. With the below code, I have tried setting the text change and text update events for txtLastScan to txtBar.SetFocus without any luck. I have an almost identical routine in another Access db that does not have this problem. In that db, txtBar.Text = " " is all it takes to set the focus back to txtBar. I've tried with and without txtBar.SetFocus on the current db and get the same results.
Thanks for any suggestions.
I need to have the focus return to the textbox, txtBar, in the code below. The focus always goes to the next field in the tab order of the form. I've changed the tab order and it always goes to the next command button or text field in the tab order. It is currently tabbing to txtLastScan. With the below code, I have tried setting the text change and text update events for txtLastScan to txtBar.SetFocus without any luck. I have an almost identical routine in another Access db that does not have this problem. In that db, txtBar.Text = " " is all it takes to set the focus back to txtBar. I've tried with and without txtBar.SetFocus on the current db and get the same results.
Thanks for any suggestions.
Code:
Private Sub txtBar_Change()
If Len(txtBar.Text) = 20 Then
LogCount = LogCount + 1
With rst
.AddNew
.Fields("BarCode") = txtBar.Text
.Fields("ScanDate") = txtScanDate.Value
.Fields("ScanNo") = ScanNo
.Fields("Quantity") = 1
.Update
End With
txtLastScan.Value = txtBar.Text
txtBar.Text = " "
txtBar.SetFocus
End If
End Sub