Full Version: Can you set Me.Dirty=True in code?
UtterAccess Forums > Microsoft® Access > Access Forms
dave1357
Is there a way to programmatically set the Me.Dirty property of a form to True? Or some other way to force a form to go to its BeforeUpdate event before it is closed or moved to a different record?
I have a situation where I need to make table updates based on user changes to unbound listboxes. Changing the listboxes does not set form's Dirty property to True, so if the user makes changes, then forgets to click the Save button and instead closes the form with the X or moves to a new record with the standard navigation buttons, the changes are lost.
All changes in the listboxes are made by double-clicks, so I was wondering if I could put something (like Me.Dirty=True, though this does not seem to work) in the DoubleClick events of the listboxes.
Oknow one approach would be to make a custom X button and custom navigation buttons, but I really want to avoid this and it seems like there must be a better way.
Thanks for any help.
- Dave
----
THere is more detail if it's useful:
I have a table of Contacts, a table of Groups, and a junction table GroupAssignments between them that tracks what contacts are in what groups.
I have form that allows the user to edit a group and what users are in the group.
On the form are two unbound listboxes, side by side, one showing a list of Contacts not in the group, the other showing the Contacts in the group. When you double-click a name in either listbox it moves over to the other listbox.
When the user clicks the Save button on the form, code goes through the listboxes to figure out how to update the GroupAssignments table.
Double-clicking in the listboxes does not set the Dirty property of the form. So if the user moves some names around in the listboxes and then either closes the form with the X or moves to a new Group record with the navigation buttons, the changes are not saved.
----
R. Hicks
Hmmmmm ....
Not tested .. but can you simply update a bound control in the form with the same value it currently is ???
This should dirty the form ...
RDH
dave1357
Ricky,
did a quick test and it looks like this does it. Why didn't I think of this? Thanks very much!
- Dave
R. Hicks
Great .. you are welcome .. wink.gif
DH
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.