Ok, trying to do what I think is a simple dlookup to verify a UPC code is in the db before I do an append. If not then I'll add it but I'm not even there yet.
My form has a text box for UPC... I'd like for this vba code to happen after the scan from my scanner (which ends with an ENTER command). That's not really happening but that's not really the point.Code:Private Sub theUPC_Enter() Dim A, B As Variant A = theUPC B = DLookup("[UPC]", "tblItems", [UPC] = A) If IsNull(B) = True Then MsgBox "Null!" Else MsgBox "Not Null!" End If End Sub
When I run the code as is I get a Runtime error on the dlookup line. I THINK it is related to the field section.
"tblItems" has several fields one is titled "UPC" so I thought this was the right way to do it.
Basically, it checks to see if the UPC code is in the table or not. I also tried DCount with the same results.
I'm just trying to learn how to use Access and I keep hitting brick walls.