Validate subform from parent form BeforeUpdate event?

M

Mark

Hi All,

I have a form with Customer Data and a subform with Customer Contact
History.

The Customer Contact History subform has a 'Next contact' date field.

I'd like to add code to validate that the subform 'Next contact' date hasn't
passed using the parent form's BeforeUpdate event, and to cancel the event
if validation fails.

When a user makes changes to the parent form data, the BeforeUpdate event
does the validation and correctly alerts the user, but will not let them
click in the subform to correct the 'Next contact' date until they undo the
changes they made to the parent form data.

Is there any way to get around this?

Thanks

Mark
 
J

John Vinson

Hi All,

I have a form with Customer Data and a subform with Customer Contact
History.

The Customer Contact History subform has a 'Next contact' date field.

I'd like to add code to validate that the subform 'Next contact' date hasn't
passed using the parent form's BeforeUpdate event, and to cancel the event
if validation fails.

Ungortunately, the BeforeUpdate event fires BEFORE you add anything to
the subform (as you have found). It must do so in order to allow
referential integrity to be enforced - unless there is a "parent"
record saved from the mainform, it's impossible to create a "child"
record.

When is the [Next Contact] value defined? Could you not do the check
there, on the subform?

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top