Dirty property of Subform

  • Thread starter Thread starter WC Lo
  • Start date Start date
W

WC Lo

How can I reference the Dirty property in a subform? I
have tried the following but it does not work.

If [Form]![subform name].Dirty then
....
End If
 
Thanks ...
BTW, does this subform (control) has Dirty property? If
so, how can it be tested?

-----Original Message-----
Try:
Forms![MainFormNameHere]! [SubformControlNameHere].Form

Explanation:
http://allenbrowne.com/casu-04.html


--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

How can I reference the Dirty property in a subform? I
have tried the following but it does not work.

If [Form]![subform name].Dirty then
....
End If


.
 
Thanks ...
BTW, does this subform (control) has Dirty property? If
so, how can it be tested?
 
No. The subform control does not have a Dirty property.

The form in the subform control does have (assuming it is bound to a table
or query), so the test would look like this:

If Forms![MainFormNameHere]![SubformControlNameHere].Form.Dirty Then


--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Thanks ...
BTW, does this subform (control) has Dirty property? If
so, how can it be tested?

-----Original Message-----
Try:
Forms![MainFormNameHere]! [SubformControlNameHere].Form

Explanation:
http://allenbrowne.com/casu-04.html


How can I reference the Dirty property in a subform? I
have tried the following but it does not work.

If [Form]![subform name].Dirty then
....
End If
 
Thanks. I don't get any syntax now. But how can I test
it? I do have changed some data in the subform. But it
still returns false to me.

-----Original Message-----
No. The subform control does not have a Dirty property.

The form in the subform control does have (assuming it is bound to a table
or query), so the test would look like this:

If Forms![MainFormNameHere]!
[SubformControlNameHere].Form.Dirty Then
--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Thanks ...
BTW, does this subform (control) has Dirty property? If
so, how can it be tested?

-----Original Message-----
Try:
Forms![MainFormNameHere]! [SubformControlNameHere].Form

Explanation:
http://allenbrowne.com/casu-04.html


How can I reference the Dirty property in a subform? I
have tried the following but it does not work.

If [Form]![subform name].Dirty then
....
End If


.
 
That might depend on when you run the test.

If you test the subform's Dirty property from (say) the Click event of a
button on the main form, Access has to move the focus to the main form. It
saves the subform record *before* focus moves to the main form, so by the
time the focus reaches there and the event runs, the subform will no longer
be dirty.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Thanks. I don't get any syntax now. But how can I test
it? I do have changed some data in the subform. But it
still returns false to me.

-----Original Message-----
No. The subform control does not have a Dirty property.

The form in the subform control does have (assuming it is bound to a table
or query), so the test would look like this:

If Forms![MainFormNameHere]!
[SubformControlNameHere].Form.Dirty Then
Thanks ...
BTW, does this subform (control) has Dirty property? If
so, how can it be tested?


-----Original Message-----
Try:
Forms![MainFormNameHere]!
[SubformControlNameHere].Form

Explanation:
http://allenbrowne.com/casu-04.html


message
How can I reference the Dirty property in a subform? I
have tried the following but it does not work.

If [Form]![subform name].Dirty then
....
End If
 
Hi Allen, thanks very much for your help. As you can tell I am very new to Access. Can you suggest a way to test the subform's Dirty property from the Click event of a button on the main form. As you say, Access will move the subform before it moves the focus to the main form. So if I have a CANCEL button in the main form, it seems I have no way to undo the saved record of the subform

Appreciate your advise.
 
That is correct: there is no way a Cancel button on the main form can work
for the record in the subform.

A Cancel button on a toolbar might work, or one in the subform itself.
However, if the user has the cursor in a Required field, backspaces the
entry out (so it's blank), they will be unable to leave the field (since it
is required), so they will not be able to click the button on the subform
either.

Best way is to forget the command button, and teach users to do one of
these:
- press the <Esc> key twice (once to undo the active field, and the second
to undo the record.)
- choose Undo from the Edit menu.
- use the Undo icon on the toolbar.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

WC LO said:
Hi Allen, thanks very much for your help. As you can tell I am very new
to Access. Can you suggest a way to test the subform's Dirty property from
the Click event of a button on the main form. As you say, Access will move
the subform before it moves the focus to the main form. So if I have a
CANCEL button in the main form, it seems I have no way to undo the saved
record of the subform.
 
Thanks Allen. I have not tested your suggestion yet. But I can imagine that there is no way to delete a record of a subform too, or to restrict the focus be noved out to the main form. So in seems the subform is not a good way for data entry for one-to-many tables, such as orderhearder and details. Do you think modal form is a solution?
 
Hi Allen

I have tested your suggestion. <ESC> cannot undo the change but the Undo on the toolbar works ... but the focus must be still within the subform.
 
Not sure I follow. A subform is brilliant for entering the detail records.
Subforms are one of the things that make Access a superb development
environment for building interfaces into relational data.

The fact that the user needs to learn to press <Esc> to back out is the
issue? Or the fact that you need to use Form_BeforeUpdate for validation
because there are many ways that will trigger Access saving the record?
--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

WC Lo said:
Thanks Allen. I have not tested your suggestion yet. But I can imagine
that there is no way to delete a record of a subform too, or to restrict the
focus be noved out to the main form. So in seems the subform is not a good
way for data entry for one-to-many tables, such as orderhearder and details.
Do you think modal form is a solution?
 
Actually main/subform is common in application development on IBM mainframe or Oracle. BTW, if a user wants to delete a record in a subform, how can it be done?
 
Several ways to delete a record:

1. Select the Record, by clicking on the Record Selector (left) or chosing
Select Record from the Edit menu, and then press the Delete key.

2. Choose Delete Record from the Edit menu.

3. Use a toolbar button.

Naturally, any database will benefit from being able to interface handle
subforms for related data, but I'm not aware of other tools that do this as
easily as Access, e.g. drag a form from the Database window onto another
form that is open in design view, and you have a subform.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

WC Lo said:
Actually main/subform is common in application development on IBM
mainframe or Oracle. BTW, if a user wants to delete a record in a subform,
how can it be done?
 
BTW, if a user wants to delete a record in a subform, how can it be done?

Select the record, press the <Delete> key; select Record... Delete
from the menu; press a custom Delete button if you've added one...
nothing at all different than deleting a record on a mainform.
 
Hi Allen,

Thanks a lot for the advise. I tried over the weekend
and it is fine to me. Thanks again.
 
Back
Top