Re: SetFocus in Form Undo event
- From: Jerry Schwartz <JerrySchwartz@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 26 Jan 2009 14:34:14 -0800
"Jeanette Cunningham" wrote:
Jerry,
some questions:
How does a user cancel an order or carry out the undo - how many different
ways can they do this?
They can only cancel changes to (or creation of) an order record with the
escape key.
Have you thought of having an order status field instead of needing to use
buttons.
On the order status field, in your form you could use a combo that has
values like - authorized, ordered, whatever else you need. That way there is
no tricky coding around order and authorize buttons. The user simply chooses
the status from the combo.
The typical user cannot authorized an order. They can enter an order, but
until the order is authorized they cannot complete the invoicing process.
Since it appears that we need to delve into the process more deeply yet,
here's what's really going on.
Certain suppliers require authorization, but most do not. This flag is set
on the supplier record.
Each order record has an "authorized by" field, but unless the supplier
requires authorization it is ignored.
When a user creates, or navigates to, an order whose supplier requires
authorization, the "authorized by" field on the record is checked. If it is
empty, then the "Authorize" button is shown and the "Order" (actually, its
function it to complete an order) button is hidden. If the supplier does not
require authorization, the "Order" button is always available.
When a user hits the "Authorize" button, they are prompted for a password.
If they type in a valid password, then their user id is entered into the
"authorized by" field; the "Authorize" button goes away; and the "Order"
button is displayed.
That all works. The problem arises if they cancel changes to an existing
order after using the "Authorize" button. The "Authorize" button will have
disappeared, the "Order" button will have appeared, but the "authorized by"
field will be reset to its previous (empty) value.
If the user navigates away from the order and back to it, the state of the
buttons will be set correctly by the Current event; but that is (IMHO) ugly.
I use this system for an inventory database. When a job is started it is
automatically given a status of open.
When the job has been completed the user chooses 'invoice' for the status.
When the job has been invoiced the user chooses 'closed' for the status.
It is easy to find all closed jobs, open jobs etc.
A drop-down would have the same problem. Remember, I don't want to show the
relevant control unless authorization is actually required.
Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia.
"Jerry Schwartz" <JerrySchwartz@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:14EF7A18-3E6E-4DF1-BFA5-0CFDE6324374@xxxxxxxxxxxxxxxx
"Jeanette Cunningham" wrote:
Hi Jerry,
when the user undoes their changes, the bound controls will be reset back
to
their OldValue.
That is precisely what I want.
Perhaps you can check the value of one control (not sure which control is
best for this), if it's value after undo is the same as its OldValue,
then
use that to hide the order control/button instead of trying to set focus.
In what event would I do that?
Unfortunately, I don't think this would help in any case. Here's a little
more explanation of what I want to do:
The user brings up an order, and it might or might not require
authorization. If the order requires authorization, then I want to display
the "Authorize" button and hide the "Order" button. If the order has
already
been authorized, then I want to display the "Order" button but not the
"Authorize" button.
This all works fine, except in one corner case:
If the user authorizes the order, but then cancels the screen (without
having previously updated the underlying data), the states of the two
buttons
do not return to their original values. This means the user no longer has
the
ability to authorize the order without navigating to another record and
then
back.
That's why I need to fiddle with the buttons when the form is cancelled. I
can't think of any other event that would do it.
As it happens, there are no bound controls that I can guarantee would have
changed, although I could make a new one and hide it somewhere. I think
I'd
still have the same problem, though, because there isn't any event that
gets
triggered after an Undo; so I don't see any place where I can check the
value
of any control.
Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
"Jerry Schwartz" <JerrySchwartz@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message
news:A865063B-89A6-434A-A4D8-0C4C66380130@xxxxxxxxxxxxxxxx
To make a long story short, I want to flip the state of a control when
the
user undoes their changes. I can't do this if the control has the
focus,
so I
need to move the focus to some other control first. My code looks
something
like this:
Private Sub Form_Undo(Cancel As Integer)
' If the associated publisher record requires authorization,
' we show the "Authorize order" button and hide the "Order sheet"
button.
Cancel = False
Me.SomewhereElse.SetFocus
Me.MyControl.Visible = False
Me.MyControl.Enabled = False
End Sub
It appears, however, that you cannot use the SetFocus method on any
control
during the Form Undo event.
Any suggestions?
- Follow-Ups:
- Re: SetFocus in Form Undo event
- From: Jeanette Cunningham
- Re: SetFocus in Form Undo event
- References:
- SetFocus in Form Undo event
- From: Jerry Schwartz
- Re: SetFocus in Form Undo event
- From: Jeanette Cunningham
- Re: SetFocus in Form Undo event
- From: Jerry Schwartz
- Re: SetFocus in Form Undo event
- From: Jeanette Cunningham
- SetFocus in Form Undo event
- Prev by Date: Re: Form greyed out unless ...
- Next by Date: Re: OnOpen Code Problem Still Exists After Workarounds
- Previous by thread: Re: SetFocus in Form Undo event
- Next by thread: Re: SetFocus in Form Undo event
- Index(es):
Relevant Pages
|