Undoing change to single field in subform

V

vainglory

Hi All,

I'm aware that I can undo a change to all fields in a record in a
subform by using the following syntax:

Forms![frmLookUpData]![subfrmComponentName].[Form].Undo

where frmLookUpData is my form and subfrmComponentName is my subform.
Yet, I don't want all the fields to be undone, just one particular
field. I've tried this:

Forms![frmLookUpData]![subfrmComponentName].[Form]![ComponentName].Undo

but it does not seem to undo the change to that particular field. It
doesn't give any errors either which is strange. Can anyone help me
with this?

Thanks!
 
R

Rick Brandt

vainglory said:
Hi All,

I'm aware that I can undo a change to all fields in a record in a
subform by using the following syntax:

Forms![frmLookUpData]![subfrmComponentName].[Form].Undo

where frmLookUpData is my form and subfrmComponentName is my subform.
Yet, I don't want all the fields to be undone, just one particular
field. I've tried this:

Forms![frmLookUpData]![subfrmComponentName].[Form]![ComponentName].Undo

but it does not seem to undo the change to that particular field. It
doesn't give any errors either which is strange. Can anyone help me
with this?

Thanks!

Since you are referencing a subform where is the code being called from? If you
have allowed focus to move to the main form then the subform has already been
saved at that point and undo is no longer going to do anything.
 
V

vainglory

Hi Rick,

The code is written in a sub in a standard module. This sub is called
by another sub in the class module of the form "On_Error" where the
control argument is passed on.

Thanks

Rick said:
vainglory said:
Hi All,

I'm aware that I can undo a change to all fields in a record in a
subform by using the following syntax:

Forms![frmLookUpData]![subfrmComponentName].[Form].Undo

where frmLookUpData is my form and subfrmComponentName is my subform.
Yet, I don't want all the fields to be undone, just one particular
field. I've tried this:

Forms![frmLookUpData]![subfrmComponentName].[Form]![ComponentName].Undo

but it does not seem to undo the change to that particular field. It
doesn't give any errors either which is strange. Can anyone help me
with this?

Thanks!

Since you are referencing a subform where is the code being called from? If you
have allowed focus to move to the main form then the subform has already been
saved at that point and undo is no longer going to do anything.
 
R

Rick Brandt

vainglory said:
Hi Rick,

The code is written in a sub in a standard module. This sub is called
by another sub in the class module of the form "On_Error" where the
control argument is passed on.

From a sub in the subform's module or the parent's? What event actually
triggers the code to run?
 
V

vainglory

Hi Rick,

Sorry about the omission. To answer your question, it's from a sub in
the subform's module. The event is an "On_Error" event.

Thanks!
 
R

Rick Brandt

vainglory said:
Hi Rick,

Sorry about the omission. To answer your question, it's from a sub in
the subform's module. The event is an "On_Error" event.

There are some things that cannot be done in certain events. For example you
cannot change the value of a control in its own BeforeUpdate event. Perhaps
Undo is simply something that doesn't work when attempted from the Error event
of the form. I don't know as I have not actually coded that scenario.

Try entering something into that control and then bring up the immediate window
and just enter...

Forms![frmLookUpData]![subfrmComponentName].[Form]![ComponentName].Undo

....then press <enter> to see if the Undo works in that scenario.
 
V

vainglory

Hi Rick

This undo works on the on error even in the subform module:

Forms![frmLookUpData]![subfrmComponentName].[Form].Undo

but not this:

Forms![frmLookUpData]![subfrmComponentName].[Form]![ComponentName].Undo

Also, if I am referencing a form with no subforms this works at on
error in the forms module:

Forms![frmLookUpData].Undo

and so does this!:

Forms![frmLookUpData]![ComponentName].Undo

It seems that I cannot reference the control in the subform. All other
possibilities work.



Rick said:
vainglory said:
Hi Rick,

Sorry about the omission. To answer your question, it's from a sub in
the subform's module. The event is an "On_Error" event.

There are some things that cannot be done in certain events. For example you
cannot change the value of a control in its own BeforeUpdate event. Perhaps
Undo is simply something that doesn't work when attempted from the Error event
of the form. I don't know as I have not actually coded that scenario.

Try entering something into that control and then bring up the immediate window
and just enter...

Forms![frmLookUpData]![subfrmComponentName].[Form]![ComponentName].Undo

...then press <enter> to see if the Undo works in that scenario.
 
R

Rick Brandt

vainglory said:
Hi Rick

This undo works on the on error even in the subform module:

Forms![frmLookUpData]![subfrmComponentName].[Form].Undo

but not this:

Forms![frmLookUpData]![subfrmComponentName].[Form]![ComponentName].Undo

Are you sure that "ComponentName" is the name of the control and not the field
that the control is bound to? Only the control has an Undo event.
 

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