Question : have msgbox display after enter serial number if conditon

Hello,
when you open this database you will see form with one button on it.
you click button and enter serial number.
form is based on query of two tables.
I have a 3rd table called tblDestroyed.
After I enter serial number, and click button.
I want an msgbox to display if the serial number is also in tblDestroyed and say something like "This is a damaged part".
is this possible
A Serial number that is in both tables -is  9NLJ45-
if you enter that I want the msgbox to display.
thank you-(database attached)
Attachments:
 
three tables
 

Answer : have msgbox display after enter serial number if conditon

assuming your textbox is named txt_SerialNum, and the command button is named cmd_CheckSerialNum, then the code might look like:

Private Sub cmd_CheckSerialNum_Click

    if isnull(DLOOKUP("Serial Num", "tblDestroyed", "[Serial Num] = '" & me.txt_SerialNum & "'")) = False then
        msgbox "This is a damaged part!"
    End if

End Sub
Random Solutions  
 
programming4us programming4us