You can make a flag to indicate validation of input.


'On the Form Module
private flagInvalidInput as Boolean

Private Sub txtWHCode_LostFocus()

'Code for getting Warehouse Name

If [Invalid Warehouse code] then
Msgbox "Invalid Code"
flagInvalidInput = True
txtWHCode.SetFocus
else
flagInvalidInput = False
end if
End Sub

Private Sub txtPartNo_LostFocus()
If Not flagInvalidInput then
'Code for getting Part Description goes here

If [Invalid Part Number] then
Msgbox "Invalid Part Number"
txtPartNo.SetFocus
end if

end if
End Sub


You can use ComboBoxes for the Warehouse Code and Part Number instead of TextBoxes.

Get the warehouse code and the part number on Form Load events and put it into comboBoxes.

If you set Style to 2-DropDown List, user are not able to type anything other than what's already in the combobox list.

This way you can avoid invalid input from user, and user don't need to remember whole warehouse code or part number.

Joon