billcute
asked on
"Send Keys" Error
What is the best code to replace the "Send Keys" code error.
This seems to have something to do with the operating systems User Account Control (UAC). Turning off/disabling UAC could be bad and I assume that disabling UAC is not a solution. Any other ideas anyone?
Problem:
A user enters a wrong data type in a text field, and the "Before Update code verify the data and informs the user that wrong type of data was entered. Upon clicking the "ok" button of the msgbox dialog box, another error popup up.
Run-Time Error '70':
"Permission denied"
debug highlighted...
SendKeys Chr(27) & Chr(27)
form this code....
' ******
Private Sub BldgDisttxt_BeforeUpdate(C ancel As Integer) '<====
Dim sError As String
Dim sMinValueCheck As String
Dim sMaxValueCheck As String
Dim bAllowFractions As Boolean
Dim bAllowX As Boolean
sMinValueCheck = ">=0"
sMaxValueCheck = "<=400"
bAllowFractions = True
bAllowX = False
BldgDisttxtNewValue = VerifyValue(Nz(Me!BldgDist txt.Value, ""), sError, sMinValueCheck, sMaxValueCheck, bAllowFractions, bAllowX)
If BldgDisttxtNewValue = "" Then
msgbox sError, vbInformation + vbOKOnly, "Invalid Value, press ESC twice to retry"
SendKeys Chr(27) & Chr(27) ' <==== Error Line
'Me!BldgDisttxt.Undo
Cancel = True
End If
End Sub
Note:
I observed the "Send Keys" problem particularly when using Ms. Access 2003 in these operating systems:
Windows Vista, XP and Windows 2K - (if this would help).
This seems to have something to do with the operating systems User Account Control (UAC). Turning off/disabling UAC could be bad and I assume that disabling UAC is not a solution. Any other ideas anyone?
Problem:
A user enters a wrong data type in a text field, and the "Before Update code verify the data and informs the user that wrong type of data was entered. Upon clicking the "ok" button of the msgbox dialog box, another error popup up.
Run-Time Error '70':
"Permission denied"
debug highlighted...
SendKeys Chr(27) & Chr(27)
form this code....
' ******
Private Sub BldgDisttxt_BeforeUpdate(C
Dim sError As String
Dim sMinValueCheck As String
Dim sMaxValueCheck As String
Dim bAllowFractions As Boolean
Dim bAllowX As Boolean
sMinValueCheck = ">=0"
sMaxValueCheck = "<=400"
bAllowFractions = True
bAllowX = False
BldgDisttxtNewValue = VerifyValue(Nz(Me!BldgDist
If BldgDisttxtNewValue = "" Then
msgbox sError, vbInformation + vbOKOnly, "Invalid Value, press ESC twice to retry"
SendKeys Chr(27) & Chr(27) ' <==== Error Line
'Me!BldgDisttxt.Undo
Cancel = True
End If
End Sub
Note:
I observed the "Send Keys" problem particularly when using Ms. Access 2003 in these operating systems:
Windows Vista, XP and Windows 2K - (if this would help).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SendKeys is an unsafe expression, blocked in sandbox mode.
What you are really trying to do is undo the control (first Esc) and then undo the record (second Esc). This corresponds to:
BldgDisttxt.Undo ' provided it's a bound control
Me.Undo ' provided it's a bound form
Cheers!
(°v°)
What you are really trying to do is undo the control (first Esc) and then undo the record (second Esc). This corresponds to:
BldgDisttxt.Undo ' provided it's a bound control
Me.Undo ' provided it's a bound form
Cheers!
(°v°)
ASKER
harfang
Thanks for additional the info. However...
BldgDisttxt.Undo ' It's not bounded
Me.Undo ' Form not bounded
data is pasted unto main form via the following..
Forms!frmMain!txtBldgDist = Me.BldgDisttxt
Regards
Bill
Thanks for additional the info. However...
BldgDisttxt.Undo ' It's not bounded
Me.Undo ' Form not bounded
data is pasted unto main form via the following..
Forms!frmMain!txtBldgDist = Me.BldgDisttxt
Regards
Bill
ASKER
Thanks