Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / April 2005

Tip: Looking for answers? Try searching our database.

Undo doesn't reset unbound controls

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Eric Norton - 06 Apr 2005 12:15 GMT
I have a scheduling form which has several unbound controls so the user can
identify the schedule they want to work with.  Due to the "crosstab with
extras" nature of the scheduling process, I've resorted to using a temporary
table and a Save button (hangs head in shame) that inserts the data back into
the (properly normalised, I promise!) permanent tables.

I want to give the user the option to change their mind if they change one
of the unbound controls to look at a different schedule, without having saved
changes back to the permanent tables.

My problem is that I cannot make the controls return to their original
states, even though I am using Cancel = True and Me!Ctrlname.Undo in the
BeforeUpdate event code for each of the controls.  The code runs, generates
no errors, cancels insofar as the AfterUpdate event doesn't fire, but leaves
the control showing its changed value - this is true for two combo boxes and
an option group containing only 2 radio buttons.

Can anybody tell me why this is so, and how to correct this behaviour?

Any assistance or advice (apart from "Don't use a temporary table and
unbound controls" - believe me, I tried to avoid it!) gratefully received!

Signature

Top 3 comments you don't want to see in other people's code:
3.   'Causes error - will resolve later
2.   'see <nonexistent reference>
1.   'can't remember what this does!!!

Andreas - 06 Apr 2005 12:40 GMT
Don't know why it does this :-(
To resolve the issue, set the controls to Null (Me.Ctrlname=Null) or a
zero length string if Null does not work (Me.Ctrlname="").

Regards,
Andreas

> I have a scheduling form which has several unbound controls so the user can
> identify the schedule they want to work with.  Due to the "crosstab with
[quoted text clipped - 17 lines]
> Any assistance or advice (apart from "Don't use a temporary table and
> unbound controls" - believe me, I tried to avoid it!) gratefully received!
Eric Norton - 06 Apr 2005 13:05 GMT
Many thanks for the help, Andreas.

Unfortunately the controls may not have been null before they were updated,
and since they are unbound, I can't use the OldValue property either.  Maybe
the two things are related - no OldValue property, so no Undoing back to the
original value.  Can't see why not though.  Anybody from Microsoft reading
this?  Why is OldValue restricted to bound controls?

> Don't know why it does this :-(
> To resolve the issue, set the controls to Null (Me.Ctrlname=Null) or a
[quoted text clipped - 24 lines]
> > Any assistance or advice (apart from "Don't use a temporary table and
> > unbound controls" - believe me, I tried to avoid it!) gratefully received!
Andreas - 06 Apr 2005 13:10 GMT
Then you might have to store the "old values" in variables and write
these values back to the controls rather than just hardcoding the values.

Regards,
Andreas

> Many thanks for the help, Andreas.
>
[quoted text clipped - 32 lines]
>>>Any assistance or advice (apart from "Don't use a temporary table and
>>>unbound controls" - believe me, I tried to avoid it!) gratefully received!
Ken Snell [MVP] - 06 Apr 2005 14:17 GMT
Bound controls have underlying buffers for storing original, in process of
being edited, and edited data. Unbound controls don't have those buffers.

OldValue uses the buffers to know what the original value was. Therefore,
OldValue and Undo are not available for unbound controls. If you want to
mimic that behavior, use an invisible textbox on the form to hold the
original value of the textbox (put value in that textbox during the form's
Load event and/or other events as appropriate) so that it can be obtained
for putting back in the textbox -- all under your programmatic control.

Signature

       Ken Snell
<MS ACCESS MVP>

> Many thanks for the help, Andreas.
>
[quoted text clipped - 46 lines]
>> > unbound controls" - believe me, I tried to avoid it!) gratefully
>> > received!
Eric Norton - 09 Apr 2005 08:35 GMT
Thanks for that Ken,

As you can see, I came to the same way of coping with this as you suggest,
but it's nice to have someone more experienced confirm it as the best way to
proceed, and to explain why OldValue doesn't work for unbound controls.

> Bound controls have underlying buffers for storing original, in process of
> being edited, and edited data. Unbound controls don't have those buffers.
[quoted text clipped - 56 lines]
> >> > unbound controls" - believe me, I tried to avoid it!) gratefully
> >> > received!
Eric Norton - 06 Apr 2005 13:09 GMT
I have come up with my own alternative, but it seems such an unwieldy
workaround that I still hope somebody can save me from it....  :-)

The workaround is to have an invisible textbox for each control which stores
the current value, and can be used to "reset" the control during the
AfterUpdate event if required, or itself be updated to the new current value
at the end of the AfterUpdate event.

> I have a scheduling form which has several unbound controls so the user can
> identify the schedule they want to work with.  Due to the "crosstab with
[quoted text clipped - 17 lines]
> Any assistance or advice (apart from "Don't use a temporary table and
> unbound controls" - believe me, I tried to avoid it!) gratefully received!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.