gherrmann22
New member
- Local time
- Yesterday, 21:01
- Joined
- Feb 9, 2018
- Messages
- 2
I am using Access 2016 and am fairly new to VBA.
I am trying to set up a way to look up already scrapped out product serial numbers when entering a request. Ultimately, I would add in a message for the person entering the data that this product has been scrapped out already.
I have a two tables that are involved. The first table is WORKORERS, and for that table I enter the data in a form. The form has a control where the serial number is entered. The Control Name is “SerialNO”. (It fills that data into the table in a field called “Serial#”.) FYI… the serial numbers are all text
The second table is called “ScrappedSNs”. It contains a list of serial numbers in the Field “SerialNumber”. At this point, I just want it to count how many instances there are of the serial number enter into the form control “SerialNO” that exist in the “ScrappedSNs” table. (It should either be 0 or 1). However, no matter what I enter, I always get a 0 returned. Here is my current, non-working code, though I have tried 20-30 variations:
Private Sub SerialNO_AfterUpdate()
Dim x As Integer
x = DCount("[SerialNumber]", "ScrappedSNs", "[SerialNumber]" = Me.SerialNO)
MsgBox (x)
End Sub
Any help would be appreciated.
I am trying to set up a way to look up already scrapped out product serial numbers when entering a request. Ultimately, I would add in a message for the person entering the data that this product has been scrapped out already.
I have a two tables that are involved. The first table is WORKORERS, and for that table I enter the data in a form. The form has a control where the serial number is entered. The Control Name is “SerialNO”. (It fills that data into the table in a field called “Serial#”.) FYI… the serial numbers are all text
The second table is called “ScrappedSNs”. It contains a list of serial numbers in the Field “SerialNumber”. At this point, I just want it to count how many instances there are of the serial number enter into the form control “SerialNO” that exist in the “ScrappedSNs” table. (It should either be 0 or 1). However, no matter what I enter, I always get a 0 returned. Here is my current, non-working code, though I have tried 20-30 variations:
Private Sub SerialNO_AfterUpdate()
Dim x As Integer
x = DCount("[SerialNumber]", "ScrappedSNs", "[SerialNumber]" = Me.SerialNO)
MsgBox (x)
End Sub
Any help would be appreciated.