Hi all I have a production tracking database that creates a new record every time a product is scanned into & out of a warehouse. I need to error-proof the system so a MsgBox pops up when an employee tries to scan a product into a warehouse when it hasn't been scanned out of the previous. I have a function ("CheckScanOut") that, when a product is scanned in, checks to see it was scanned out of the previous warehouse, here is the code:
There is an existing record for the serial number I am testing with, so the error can't be due to a Null value. Also, the value passed to this function (varProductSerialNumber) is Dim'ed as a string, but I get the following error: "Compile error: ByRef argument type mismatch" when the following line of code passes an input to CheckScanOut...
Please let me know if you need more info!
Code:
Public Function CheckScanOut(varProductSerialNumber As String) As Boolean 'receive ProductSerial as input and output=true/false (true if OUT_employee exisits, false if not or
Dim maxID As Long
Dim varOUTEmployee As Variant
Dim TestVar As String
maxID = DMax("[Transaction_ID]", "tbl_Transaction_Master", "[ProductSerialNumber]='" & varProductSerialNumber & "'") ''" & varProductSerialNumber & "'"
varOUTEmployee = (DLookup("[OUT_Employee]", "tbl_Transaction_Master", "[Transaction_ID]=" & maxID))
CheckScanOut = Not IsNull(varOUTEmployee)
End Function
There is an existing record for the serial number I am testing with, so the error can't be due to a Null value. Also, the value passed to this function (varProductSerialNumber) is Dim'ed as a string, but I get the following error: "Compile error: ByRef argument type mismatch" when the following line of code passes an input to CheckScanOut...
Code:
If CheckScanOut(varProductSerialNumber) = True Then 'if out_employee does exist in previous warehouse
Please let me know if you need more info!