Access2003, SendKeys and Vista

B

BEJ

Hi,

We have had another Vista 'problem' popup. It is related to Vista security
settings.

We use the `SendKeys` function in the `BeforeUpdate` event of some controls
to send the `Esc` key and clear an invalid entry from a text box, check box,
etc. The `Undo` method works on bound controls, but on unbound controls the
`Undo` method does not do anything and `SendKeys` is the best we have been
able to find. Vista apparently blocks programmatic keyboard actions (makes
some sense), so now these `BeforeUpdate` functions generate an error and
create a confusing user situation. We have tried numerous local policy
settings changes, but the only thing that works is turning off User Account
Control. Seems a little drastic.

Any ideas for replacing `SendKeys` or getting around Vista security without
disabling UAC? Any suggestions greatly appreciated.
 
K

Klatuu

Sendkeys should be avoided.
As you stated, the Undo does nothing for unbound controls.
Use:
Me.ControlName = Null
 
B

BEJ

Thanks; were it only that simple. This generates an error in BeforeUpdate.
But you did stimulate me to keep trying. I think I found a solution by
setting a modular boolean variable to false on control 'Enter', set it to
true if the value fails the test in BeforeUpdate, then act on it in
AfterUpdate, if it is true. Somewhat complex, but it works at first test.

I'll try more next week. Any other ideas?
 
K

Klatuu

What error did you get in the Before Update? Was it the Form or the Control
Before Update? Post the code for the event and point out the line where the
error occured.
 
B

BEJ

Here is the code in txtControl_BeforeUpdate; txtControl and intY are the
control and some variable.

If Me.txtControl < intY then
MsgBox "No, No!"
Cancel = True
Me.txtControl = Null
End If

This errors on Me.txtControl=Null, with Err.Number = '-2147352567',
Err.Description='The macro or function set to the BeforeUpdate . . . is
preventing Access from saving the data in the field'

No Validation Rule on this control. This is the only place we use SendKeys.
In place of Me.txtControl=Null, we use SendKeys "{Esc},[Esc}". Worked great
until Vista.

If you have a simple solution to this, please let me know. Thanks for your
input.
 
K

Klatuu

You can't change the value there
Two Escapes will Undo the entire record. One will undo the control.
All you need is the Undo either for the control or the form, depending on
what you want:

If Me.txtControl < intY then
MsgBox "No, No!"
Cancel = True
Me.txtControl.Undo
End If


--
Dave Hargis, Microsoft Access MVP


BEJ said:
Here is the code in txtControl_BeforeUpdate; txtControl and intY are the
control and some variable.

If Me.txtControl < intY then
MsgBox "No, No!"
Cancel = True
Me.txtControl = Null
End If

This errors on Me.txtControl=Null, with Err.Number = '-2147352567',
Err.Description='The macro or function set to the BeforeUpdate . . . is
preventing Access from saving the data in the field'

No Validation Rule on this control. This is the only place we use SendKeys.
In place of Me.txtControl=Null, we use SendKeys "{Esc},[Esc}". Worked great
until Vista.

If you have a simple solution to this, please let me know. Thanks for your
input.
 
B

BEJ

This is an unbound form and unbound control, so Undo does nothing. The
SendKeys works! Just not in Vista.

Klatuu said:
You can't change the value there
Two Escapes will Undo the entire record. One will undo the control.
All you need is the Undo either for the control or the form, depending on
what you want:

If Me.txtControl < intY then
MsgBox "No, No!"
Cancel = True
Me.txtControl.Undo
End If


--
Dave Hargis, Microsoft Access MVP


BEJ said:
Here is the code in txtControl_BeforeUpdate; txtControl and intY are the
control and some variable.

If Me.txtControl < intY then
MsgBox "No, No!"
Cancel = True
Me.txtControl = Null
End If

This errors on Me.txtControl=Null, with Err.Number = '-2147352567',
Err.Description='The macro or function set to the BeforeUpdate . . . is
preventing Access from saving the data in the field'

No Validation Rule on this control. This is the only place we use
SendKeys.
In place of Me.txtControl=Null, we use SendKeys "{Esc},[Esc}". Worked
great
until Vista.

If you have a simple solution to this, please let me know. Thanks for
your
input.

Klatuu said:
What error did you get in the Before Update? Was it the Form or the
Control
Before Update? Post the code for the event and point out the line
where
the
error occured.
--
Dave Hargis, Microsoft Access MVP


:

Thanks; were it only that simple. This generates an error in
BeforeUpdate.
But you did stimulate me to keep trying. I think I found a solution
by
setting a modular boolean variable to false on control 'Enter', set it
to
true if the value fails the test in BeforeUpdate, then act on it in
AfterUpdate, if it is true. Somewhat complex, but it works at first
test.

I'll try more next week. Any other ideas?


Sendkeys should be avoided.
As you stated, the Undo does nothing for unbound controls.
Use:
Me.ControlName = Null
--
Dave Hargis, Microsoft Access MVP


:

Hi,

We have had another Vista 'problem' popup. It is related to Vista
security
settings.

We use the `SendKeys` function in the `BeforeUpdate` event of some
controls
to send the `Esc` key and clear an invalid entry from a text box,
check
box,
etc. The `Undo` method works on bound controls, but on unbound
controls
the
`Undo` method does not do anything and `SendKeys` is the best we
have
been
able to find. Vista apparently blocks programmatic keyboard actions
(makes
some sense), so now these `BeforeUpdate` functions generate an
error
and
create a confusing user situation. We have tried numerous local
policy
settings changes, but the only thing that works is turning off User
Account
Control. Seems a little drastic.

Any ideas for replacing `SendKeys` or getting around Vista security
without
disabling UAC? Any suggestions greatly appreciated.
 
K

Klatuu

Then you need another place to put the code. Would it work for you if you
put it in the After Update event?

If Me.txtControl < intY then
MsgBox "No, No!"
Me.txtControl = Null
End If

--
Dave Hargis, Microsoft Access MVP


BEJ said:
This is an unbound form and unbound control, so Undo does nothing. The
SendKeys works! Just not in Vista.

Klatuu said:
You can't change the value there
Two Escapes will Undo the entire record. One will undo the control.
All you need is the Undo either for the control or the form, depending on
what you want:

If Me.txtControl < intY then
MsgBox "No, No!"
Cancel = True
Me.txtControl.Undo
End If


--
Dave Hargis, Microsoft Access MVP


BEJ said:
Here is the code in txtControl_BeforeUpdate; txtControl and intY are the
control and some variable.

If Me.txtControl < intY then
MsgBox "No, No!"
Cancel = True
Me.txtControl = Null
End If

This errors on Me.txtControl=Null, with Err.Number = '-2147352567',
Err.Description='The macro or function set to the BeforeUpdate . . . is
preventing Access from saving the data in the field'

No Validation Rule on this control. This is the only place we use
SendKeys.
In place of Me.txtControl=Null, we use SendKeys "{Esc},[Esc}". Worked
great
until Vista.

If you have a simple solution to this, please let me know. Thanks for
your
input.

What error did you get in the Before Update? Was it the Form or the
Control
Before Update? Post the code for the event and point out the line
where
the
error occured.
--
Dave Hargis, Microsoft Access MVP


:

Thanks; were it only that simple. This generates an error in
BeforeUpdate.
But you did stimulate me to keep trying. I think I found a solution
by
setting a modular boolean variable to false on control 'Enter', set it
to
true if the value fails the test in BeforeUpdate, then act on it in
AfterUpdate, if it is true. Somewhat complex, but it works at first
test.

I'll try more next week. Any other ideas?


Sendkeys should be avoided.
As you stated, the Undo does nothing for unbound controls.
Use:
Me.ControlName = Null
--
Dave Hargis, Microsoft Access MVP


:

Hi,

We have had another Vista 'problem' popup. It is related to Vista
security
settings.

We use the `SendKeys` function in the `BeforeUpdate` event of some
controls
to send the `Esc` key and clear an invalid entry from a text box,
check
box,
etc. The `Undo` method works on bound controls, but on unbound
controls
the
`Undo` method does not do anything and `SendKeys` is the best we
have
been
able to find. Vista apparently blocks programmatic keyboard actions
(makes
some sense), so now these `BeforeUpdate` functions generate an
error
and
create a confusing user situation. We have tried numerous local
policy
settings changes, but the only thing that works is turning off User
Account
Control. Seems a little drastic.

Any ideas for replacing `SendKeys` or getting around Vista security
without
disabling UAC? Any suggestions greatly appreciated.
 
B

BEJ

Yes, I guess that's what we'll have to do. Thanks for your input. It was
really helpful.

Klatuu said:
Then you need another place to put the code. Would it work for you if you
put it in the After Update event?

If Me.txtControl < intY then
MsgBox "No, No!"
Me.txtControl = Null
End If

--
Dave Hargis, Microsoft Access MVP


BEJ said:
This is an unbound form and unbound control, so Undo does nothing. The
SendKeys works! Just not in Vista.

Klatuu said:
You can't change the value there
Two Escapes will Undo the entire record. One will undo the control.
All you need is the Undo either for the control or the form, depending
on
what you want:

If Me.txtControl < intY then
MsgBox "No, No!"
Cancel = True
Me.txtControl.Undo
End If


--
Dave Hargis, Microsoft Access MVP


:

Here is the code in txtControl_BeforeUpdate; txtControl and intY are
the
control and some variable.

If Me.txtControl < intY then
MsgBox "No, No!"
Cancel = True
Me.txtControl = Null
End If

This errors on Me.txtControl=Null, with Err.Number = '-2147352567',
Err.Description='The macro or function set to the BeforeUpdate . . .
is
preventing Access from saving the data in the field'

No Validation Rule on this control. This is the only place we use
SendKeys.
In place of Me.txtControl=Null, we use SendKeys "{Esc},[Esc}". Worked
great
until Vista.

If you have a simple solution to this, please let me know. Thanks for
your
input.

What error did you get in the Before Update? Was it the Form or the
Control
Before Update? Post the code for the event and point out the line
where
the
error occured.
--
Dave Hargis, Microsoft Access MVP


:

Thanks; were it only that simple. This generates an error in
BeforeUpdate.
But you did stimulate me to keep trying. I think I found a
solution
by
setting a modular boolean variable to false on control 'Enter', set
it
to
true if the value fails the test in BeforeUpdate, then act on it in
AfterUpdate, if it is true. Somewhat complex, but it works at
first
test.

I'll try more next week. Any other ideas?


Sendkeys should be avoided.
As you stated, the Undo does nothing for unbound controls.
Use:
Me.ControlName = Null
--
Dave Hargis, Microsoft Access MVP


:

Hi,

We have had another Vista 'problem' popup. It is related to
Vista
security
settings.

We use the `SendKeys` function in the `BeforeUpdate` event of
some
controls
to send the `Esc` key and clear an invalid entry from a text
box,
check
box,
etc. The `Undo` method works on bound controls, but on unbound
controls
the
`Undo` method does not do anything and `SendKeys` is the best we
have
been
able to find. Vista apparently blocks programmatic keyboard
actions
(makes
some sense), so now these `BeforeUpdate` functions generate an
error
and
create a confusing user situation. We have tried numerous local
policy
settings changes, but the only thing that works is turning off
User
Account
Control. Seems a little drastic.

Any ideas for replacing `SendKeys` or getting around Vista
security
without
disabling UAC? Any suggestions greatly appreciated.
 
K

Klatuu

Glad I could help
--
Dave Hargis, Microsoft Access MVP


BEJ said:
Yes, I guess that's what we'll have to do. Thanks for your input. It was
really helpful.

Klatuu said:
Then you need another place to put the code. Would it work for you if you
put it in the After Update event?

If Me.txtControl < intY then
MsgBox "No, No!"
Me.txtControl = Null
End If

--
Dave Hargis, Microsoft Access MVP


BEJ said:
This is an unbound form and unbound control, so Undo does nothing. The
SendKeys works! Just not in Vista.

You can't change the value there
Two Escapes will Undo the entire record. One will undo the control.
All you need is the Undo either for the control or the form, depending
on
what you want:

If Me.txtControl < intY then
MsgBox "No, No!"
Cancel = True
Me.txtControl.Undo
End If


--
Dave Hargis, Microsoft Access MVP


:

Here is the code in txtControl_BeforeUpdate; txtControl and intY are
the
control and some variable.

If Me.txtControl < intY then
MsgBox "No, No!"
Cancel = True
Me.txtControl = Null
End If

This errors on Me.txtControl=Null, with Err.Number = '-2147352567',
Err.Description='The macro or function set to the BeforeUpdate . . .
is
preventing Access from saving the data in the field'

No Validation Rule on this control. This is the only place we use
SendKeys.
In place of Me.txtControl=Null, we use SendKeys "{Esc},[Esc}". Worked
great
until Vista.

If you have a simple solution to this, please let me know. Thanks for
your
input.

What error did you get in the Before Update? Was it the Form or the
Control
Before Update? Post the code for the event and point out the line
where
the
error occured.
--
Dave Hargis, Microsoft Access MVP


:

Thanks; were it only that simple. This generates an error in
BeforeUpdate.
But you did stimulate me to keep trying. I think I found a
solution
by
setting a modular boolean variable to false on control 'Enter', set
it
to
true if the value fails the test in BeforeUpdate, then act on it in
AfterUpdate, if it is true. Somewhat complex, but it works at
first
test.

I'll try more next week. Any other ideas?


Sendkeys should be avoided.
As you stated, the Undo does nothing for unbound controls.
Use:
Me.ControlName = Null
--
Dave Hargis, Microsoft Access MVP


:

Hi,

We have had another Vista 'problem' popup. It is related to
Vista
security
settings.

We use the `SendKeys` function in the `BeforeUpdate` event of
some
controls
to send the `Esc` key and clear an invalid entry from a text
box,
check
box,
etc. The `Undo` method works on bound controls, but on unbound
controls
the
`Undo` method does not do anything and `SendKeys` is the best we
have
been
able to find. Vista apparently blocks programmatic keyboard
actions
(makes
some sense), so now these `BeforeUpdate` functions generate an
error
and
create a confusing user situation. We have tried numerous local
policy
settings changes, but the only thing that works is turning off
User
Account
Control. Seems a little drastic.

Any ideas for replacing `SendKeys` or getting around Vista
security
without
disabling UAC? Any suggestions greatly appreciated.
 

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