Forms : Main------>SubForm1------>Subform2
Controls : Main ------->SupplierName
SubForm2-------->Product
The Product combo on SubForm2 has list of products based on SupplierName on MainForm. If the user does not select the supplier name, the Product combo will not have any data. I am trying to prompt the user to select Supplier in such case. The following code achieves the required result but ....
Code:
Private Sub Product_GotFocus()
If IsNull(Forms!Main!SupplierName) = True ThenMsgBox "Select supplier name", vbInformation
Forms!Main.SupplierName.SetFocus
Forms!Main.SupplierName.Dropdown
End If
End Sub
Problem : If the user leaves the SupplierName blank and then clicks on any of the controls on SubForm1 or SubForm2, the above code continues to execute till SupplierName is selected.
How to prevent repeated execution of the above code except when the Product combo on SubForm2 has focus?