I hope someone can tell me what I am doing wrong.
I have two forms. The first one, which I later put into the other form as an unrelated subform is called UPCSubfrm. It’s record source is Tbl: Product Information. This form has a bound text field for the ProductID and an Unbound text field called ScannedUPC into which I scan in the UPC for various products.
For the After Update event I use the code:
Expand|Select|Wrap|Line Numbers
- Private Sub ScannedUPC_AfterUpdate()
- If (ScannedUPC & vbNullString) = vbNullString Then Exit Sub
- Dim rs As DAO.Recordset
- Set rs = Me.RecordsetClone
- rs.FindFirst "[SKU]=""" & ScannedUPC & """"
- If rs.NoMatch Then
- MsgBox "Sorry, no such record '" & ScannedUPC & "' was found.", _
- vbOKOnly + vbInformation
- Else
- Me.Recordset.Bookmark = rs.Bookmark
- End If
- rs.Close
- ScannedUPC = Null
- End Sub
This works great. I scan in the UPC and the ProductID is displayed.
If I then put this form, UPCLookup, in the second form (as a subform) with no attached master/child relationship (I will send the ProductID to a field in the other form later) and enter a scanned UPC (SKU, I got these terms mixed up at the start), it no longer works. It gives me the “no such record message”.
In short, why does the code work in the form when it is used separately but fails to work when it is used as a subform?
Thank you
Window 7
Access 2007