hi,
when i enter invalid no below code is working fine
If Me.ProductID.Value <> DLookup("ProductId", "Products") Then
MsgBox "wrong no"
SendKeys "{home}"
Undo
but if ProductID is blank below code is not working
If isnull(me.ProductId) or Me.ProductID = "" Then
Me.ProductID.SetFocus
SendKeys "{home}"
please give me a solution to work both option
--------------------------------------------------------------------------
Private Sub ProductID_AfterUpdate()
On Error GoTo Err_ProductID_AfterUpdate
Dim strfilter As String
strfilter = "productID=" & Me!ProductID
Me!UnitPrice = DLookup("UnitPrice", "Products", strfilter)
Me.ProductID.SetFocus
Exit_ProductID_Afterupdate:
Exit Sub
Err_ProductID_AfterUpdate:
If Me.ProductID.Value <> DLookup("ProductId", "Products") Then
MsgBox "wrong no"
SendKeys "{home}"
Undo
Else
If isnull(me.ProductId) or Me.ProductID = "" Then
Me.ProductID.SetFocus
SendKeys "{home}"
End If
End If
End Sub