Running the command Cancel=MyVerify in parent form

R

Rich

I have a function that is called by the command Cancel=MyVerify that
is triggered by the before update event. It works great to prevent me
from leaving certain fields blank in a form.

However I also want to trigger this function from a subform incase the
user goes right to the subform without entering data in the parent.

How can I call this function from the subform? For some reason I
can't get the parent syntax right
 
A

Albert D. Kallal

When you go from the main form to the sub form, the main record HAS TO BE
SAVED. In fact, ms-access does this for you.

So, in effect, if you got your verify code correctly setup, the instant the
user tries to enter some data in the sub-form, the main form record is saved
(in fact, it has to be saved...since those sub form "child" records NEED a
parent record to relate to. You CAN NOT enter sub-form records without the
parent record first being saved.

So, in effect, if your main form verify code is working...you don't have to
do a thing....
 
R

Rich

That is exactly the problem I am having. It may be because I am using sql
linked tables but the parent record is not getting saved unless I enter some
data into the parent form. If I just load the form and click into the
subform the parent record never gets saved.

Maybe what I need to do then is when I click into the subform to save the
parent form, which will inturn run the function to verify the data. This
leads me to the same problem which is I dont know the syntax to save the
parent form.
 
A

Albert D. Kallal

Ok, perhaps with linked sql tables, the parent reocrd is not auto
saved...but that is new to me...

You could try and force a save..and that would trigger your "veryify code".

However, I would actually just run the verify code..and thus you don't have
to have the reocrd saved. (that way, the user can bail out and close the
form..and no "main" parent reocrd need be created.

So, I would either

a) - run the verify code in the on enter event of the sub-forms

b) - force a save in the on enter event of the sub-form contorl.

I would actually try option a)

Simply use the sub-form controls on-enter event...and go:

MyVerify

If the MyViefy code sets the focus for any verification, then the above
should work for you.
 
Top