Setting dirty =true on Main Form

G

Guest

Hello
I have Main and subform

I am trying to set the dirty prpoerty of main form to true if sub form is
changed
I put this code in BeforeupdateEvent of subform

If Me.Dirty Then
Me.Parent.Dirty = True
End If

Howevr i have an error " In order to change data through this form, the
focus must be in a bound field that can be modified."

How can I solve this problem

Thank you and best regsrds
 
A

Allen Browne

While I cannot think of a good reason to dirty the parent form, and the idea
of those additional unnecessary writes bothers me, you can do it just by
assigning a value to any control on the main form.

For example, you could assign the value of the City text box to itself:
With Me.Parent!City
.Value = .Value
End With

There is no need to test if this form is dirty: its BeforeUpdate event will
not occur if it is not (unless you are calling it yourself.)
 
G

Guest

Hello Allen
Thank you for your reply.

The reason I want to make the Main form dirty, is that I have a certain code
that must run in the BeforeUpdateEvent of the Main form if it is dirty and
based on another condition .
"If dirty and me.savech=true then....."
If I change data in subform only the main form is not dirty and this code
doesn't run.
If I add this code to the BeforeUpdateEvent of the subform, it will run each
time I change between subform and main form.

Perhaps this is not a good approach, if you have any advice. Please tell me.

Best Regards
Bassel
 

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