var = DLookup(PartNumber, "temptobom", EquationPartNumber = Epn And toNumber = Num)
If Not IsNull(var) Then
If MsgBox("此部件已添加,需要继续编辑吗?", 4) = 7 Then
Exit Sub
End If
Else
DoCmd.SetWarnings False
DoCmd.OpenQuery "qrytointo"
DoCmd.RunSQL "INSERT INTO temptobom SELECT temp.* FROM temp" _
& " WHERE (((temp.toNumber)='" & Num & "') AND ((temp.EquationPartNumber)='" & Epn & "'));"
DoCmd.RunSQL "DELETE temp.* FROM temp;"
DoCmd.SetWarnings True
End If