Hey Everybody,
I have a form with a label ("Enter Password"), a textbox (with a password InputMask), and two command buttons ("OK" and "Cancel"). I've successfully written code for the "OK" command button to check the password in the textbox with an OnClick event. It then either opens the authorized form or it doesn't.
However, I would also like to set an event for the textbox, so when the user hits the Enter key, the same code is executed as for the "OK" button's OnClick event. I tried running the code below, but I kept getting a response stating, "This action can't be carried out while processing a form or report event." - Private Sub txtEnterPassword_Exit(Cancel As Integer)
-
On Error GoTo Err_txtEnterPassword_Exit
-
-
Dim stDocName As String, stLinkCriteria As String
-
-
If Me.txtEnterPassword = "proc_eng" Then
-
' Password is correct; open form below and exit Main Menu.
-
stDocName = "Add Column"
-
DoCmd.OpenForm stDocName, , , stLinkCriteria
-
DoCmd.Close acForm, "Main Menu"
-
DoCmd.Close acForm, "Authorization Required"
-
Else
-
MsgBox "Incorrect Password", vbOKOnly, "Access Denied"
-
' Password is incorrect.
-
End If
-
-
Exit_txtEnterPassword_Exit:
-
Exit Sub
-
-
Err_txtEnterPassword_Exit:
-
MsgBox Err.Description
-
Resume Exit_txtEnterPassword_Exit
-
End Sub
I found that the DoCmd.Close acForm, "Authorization Required" line of code was the problem. If I delete it, the rest of the code works. However, I need that form to close. What did I do wrong? How do I fix it? Please post the exact changes that need to be made.
Thanks!
4 1573
Hey Everybody,
I have a form with a label ("Enter Password"), a textbox (with a password InputMask), and two command buttons ("OK" and "Cancel"). I've successfully written code for the "OK" command button to check the password in the textbox with an OnClick event. It then either opens the authorized form or it doesn't.
However, I would also like to set an event for the textbox, so when the user hits the Enter key, the same code is executed as for the "OK" button's OnClick event. I tried running the code below, but I kept getting a response stating, "This action can't be carried out while processing a form or report event." - Private Sub txtEnterPassword_Exit(Cancel As Integer)
-
On Error GoTo Err_txtEnterPassword_Exit
-
-
Dim stDocName As String, stLinkCriteria As String
-
-
If Me.txtEnterPassword = "proc_eng" Then
-
' Password is correct; open form below and exit Main Menu.
-
stDocName = "Add Column"
-
DoCmd.OpenForm stDocName, , , stLinkCriteria
-
DoCmd.Close acForm, "Main Menu"
-
DoCmd.Close acForm, "Authorization Required"
-
Else
-
MsgBox "Incorrect Password", vbOKOnly, "Access Denied"
-
' Password is incorrect.
-
End If
-
-
Exit_txtEnterPassword_Exit:
-
Exit Sub
-
-
Err_txtEnterPassword_Exit:
-
MsgBox Err.Description
-
Resume Exit_txtEnterPassword_Exit
-
End Sub
I found that the DoCmd.Close acForm, "Authorization Required" line of code was the problem. If I delete it, the rest of the code works. However, I need that form to close. What did I do wrong? How do I fix it? Please post the exact changes that need to be made.
Thanks!
Can someone help me?
MMcCarthy 14,534
Recognized Expert Moderator MVP
Try putting your code in the After Update event of the textbox
hyperpau 184
Recognized Expert New Member
Can someone help me?
Put an after_update event on the txtbox
that would set focus on the OK key.
So as soon as user inputs text, focus goes to OK key and
the moment they press enter, the ok key function is called
I had the same problem once and I changed the order and it works
try to do that ...
DoCmd.Close acForm, "Authorization Required"
DoCmd.Close acForm, "Main Menu"
DoCmd.OpenForm stDocName, , , stLinkCriteria
I'm not an expert member but I think it will works ..please try it and tell me if it works
thank you
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Bobby |
last post by:
Hello everyone I have a question. The school I am working for is in
the beginning process of having a webpage that will direct students to
download there homework and be able to view there info...
|
by: carr4895 |
last post by:
Hello.
I was wondering if someone could help me too with a login form. Upon
startup, I have to display a password screen and it should accept a
user name and password. User name can be anything...
|
by: Gaby |
last post by:
Hi guys,
I have this ASP code that is a little long to post so but you can
download it off of
http://whatthedeuce.net/Form.asp
I cant find out what my error is. I know it is not in my Access...
|
by: wipit |
last post by:
I need to process a HTML form in python. I'm using urllib2 and
HTMLParser to handle the html. There are several steps I need to take
to get to the specific page on the relevant site the first of...
|
by: Vash10 |
last post by:
I have two asp files. Login.asp and changePass.asp. what i want to do is to make the user change his password after his first login. so what happens is login.asp is the first to be used then it is...
| |
by: mabzkie |
last post by:
whats wrong with my codes? i need to login using two textfields: txtuser for the username and txtpass for the password. i am using ado and ms access as a database. when i tried to enter with a long...
|
by: eragon |
last post by:
I am making a password script, i have most of it done, ill show you, but i hit a brick wall.... lol, I have it so when you log in it takes you to your main page, that works, but when you enter the...
|
by: chaos |
last post by:
Hi all, i need help in this forgot password page, as the error message is show in another page cause the arrangement of the design in a mess. As i want to show the error message on the forgot...
|
by: bmallett |
last post by:
I am getting the following error:
Error Type:
ADODB.Command (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another....
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |