Dirty event not occur

M

Martin

Hi,
I have a bound form in Access XP. I use event Dirty and Undo to activate and
deactivate some commandbuttons (as SAVE).
When I edit an existing record, Dirty event occurs, when data is changed.
But when I the record is new, Dirty event doesnot occurs, allthough the
property Dirty of the form is true.

Why?
Thanks
 
A

Allen Browne

The Dirty event does fire for a new record if the user enters something.

It does not fire in Access 2002 if you dirty the record programmatically.
 
M

Martin

I know this.
In my case, I set the recordsource property of this form dynamically. In
designtime this property = "", DataEntry = true

In Runtime I set:
f.recordsource = "xxx"
DoCmd.GoToRecord , , acNewRec

Now I type any word in a control. But the event is not fired.
 
A

Allen Browne

I am unable to repro that Martin.

Created a form with nothing in its RecordSource property, and DataEntry set
to Yes. In Form_Load, assigned a table name to RecordSource. Added a
debug.print line to the Dirty event, and it fired fine, both in Access 2002
and 2003.
 
M

Martin

I have moved the line f.recordsource = "xxx" to another place, then it
works. I don't know, how. But I will try to repro this scenario and tell
you.
Thanks
 
A

Allen Browne

Okay, so that may be the resolution.

Just for the record, Form_Open would probably be the most desirable place to
assign the RecordSource initially (rather than Form_Load).
 

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