I have a simple form with a subform. In the main form is a field for the user to scan a UPC code. The UPC is found in the recordset then the subform is requeried to display the scanned item. The last command in the sub sets focus back to the UPC field in the main form for the next scan. Everything works except for setfocus. Tried decompile & C/R also imported all to new db.
Dim db As Database
Dim rstManifest As Recordset
Dim strUPC As String
Dim strLotNum As String
Dim strCriteria As String
Set db = CurrentDb
Set rstManifest = db.OpenRecordset("tblManifest", dbOpenDynaset)
strUPC = Me.UPCScan
strLotNum = Me.LotNum
strCriteria = "[UPC] = '" & strUPC & "' And [Scanned] = False"
With rstManifest
.MoveFirst
.FindFirst strCriteria
If rstManifest.NoMatch Then
MsgBox "UPC Item " & strUPC & " not found", vbOKOnly, "Try Again"
GoTo Cleanup
Else
.Edit
!LotNum = Me.LotNum
!DateItemAdded = Now()
!Scanned = True
.Update
Me!Manifest.Form.Requery
End If
End With
Cleanup:
If IsNull(Me.LotNum Or Me.LotNum = "") Then
Me.LotNum = strLotNum
End If
Me!UPCScan = Null
Me.UPCScan.SetFocus 'This line does not work
'DoCmd.GoToControl "UPCScan" 'Does not work either
rstManifest.Close
Set rstManifest = Nothing
Set db = Nothing