tags:

views:

1158

answers:

2

OK, I have several controls on a parent form, along with a subform. The user enters data in the subform. Then when they click off the subform, I have code to validate their data. However, MS in its infinite wisdom, has chosen to not let the focus leave the subform until the user clicks another control on the parent form (instead of the parent form itself), which is very annoying for the user.

Basically all I want to do is validate the data in the subform before allowing the user to continue to the next control, even when the user clicks the parent form itself. Is this possible?

A: 

I think you are going to have to hook the Form_Click event on the main form and do something with it. Setting the focus to a field on the main form might cause the subform to fire the event having the validation code.

If that doesn't work, fire the validation code on the subform manually on Form_Click of the main form like this:

Call Forms!MainForm!Subform.Form.Validate

It's been awhile so my Access VB is a little rusty, YMMV.

Robert Harvey
+1  A: 

You could probably do this on the "OnExit" event of the subform control you used.

The "OnExit" event is generally fired when a control on the subform loses focus for a control of the parent form. It is not present in the subform itself but it's one of the only two events for the control which contains the subform.

Hope that helps.

Marcand