Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limit Message to the Active Form

Status
Not open for further replies.

LeoLily

Technical User
Jun 30, 2005
9
US
Hello- I have several subforms within one form. Each subform has code in it that alerts the user that he/she did not fill in a required field - example follows:

If IsNull(Me.X) = True Then
MsgBox "Click on Intensity level."
Me.y.SetFocus
Me.x.SetFocus
End If

The problem here is that if the user fails to fill in any given field, then all of the messages from all of the subforms pop up. How can I rewrite the above to limit the error message to just the current control on the current form?
 
Sorry but I can't think of any situation where a subform event would fire if that subform does not have the focus (except if it is called through code).
All i can suggest is that you but a breakpoint into the first event procedure and follow the code through to see if you can track the problem that way.
 
Here is a sample code that set focus on subform's field if it is null. You need to change the Null check to required type as per your data to be entered.
Code:
   If IsNull(Forms!FrmEmpMaster.FrmEmpSub.Form.Salutation) Then
        MsgBox "Please enter Salutation !", _
               vbInformation + vbOKOnly, _
               "My DB Name"
        Forms!FrmEmpMaster.FrmEmpSub.Form.SomeOthercontrol.SetFocus
        Forms!FrmEmpMaster.FrmEmpSub.Form.Salutation.SetFocus
Also use "Exit Sub" for a code to break at runtime.

________________________________________
Zameer Abdulla
Visit Me
Minds are like parachutes. They only function when they are open. -Sir James Dewar (1877-1925)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top