Private Sub txtscan_AfterUpdate()
If Me.txtscan = "" Or IsNull(Me.txtscan) = True Then
MsgBox "No barcode/serial detected", vbOKOnly + vbExclamation, "Error"
Else
Dim rst As DAO.Recordset
Dim rst1 As DAO.Recordset
Dim strSQL As String
Dim strSQL1 As String
strSQL = "SELECT NetDevice_HR_Type FROM networkdevices WHERE netdevice_serial = '" & Me.txtscan & "'"
strSQL1 = "SELECT Device_HR_Type FROM devices WHERE device_serial = '" & Me.txtscan & "'"
Set rst = CurrentDb.OpenRecordset(strSQL)
Set rst1 = CurrentDb.OpenRecordset(strSQL1)
If rst.RecordCount <> 0 Then
If rst!NetDevice_HR_Type = "NAF" Or IsNull(NetDevice_HR_Type) = True Then
MsgBox "NAF/Non Assigned devices cannot be processed", vbOKOnly + vbExclamation, "Error"
Me.txtscan = ""
Me.cmdclose.SetFocus
Me.txtscan.SetFocus
Else
'Insert code here
End If
Else
If rst1.RecordCount <> 0 Then
If rst1!Device_HR_Type = "NAF" Or IsNull(rst1!Device_HR_Type) = True Then
MsgBox "NAF/Non Assigned devices cannot be processed", vbOKOnly + vbExclamation, "Error"
Me.txtscan = ""
Me.cmdclose.SetFocus
Me.txtscan.SetFocus
Else
'Insert code here
End If
Else
MsgBox "Device not found", vbOKOnly + vbExclamation, "Error"
Me.txtscan = ""
Me.cmdclose.SetFocus
Me.txtscan.SetFocus
End If
End If
End If
End Sub