473,831 Members | 2,230 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using a pop-up box to input a password?

greeni91
61 New Member
Hi Guys,

I am looking for a way to bring up an input box to insert a password to unlock a field in a form. I am trying to do it so that if you tick a tick box, "ONTick" then the field will lock, but when someone tries to untick the box it prompts for a password. I don't have the slightest clue where to start and have been staring at a For Dummies book for a good few days now.

Useful Info:

Field I am trying to lock is called "OperatorNa me"

The tick box is called "ONTick"


Thanks in Advance for any help

/Sandy
Dec 14 '09 #1
5 9167
missinglinq
3,532 Recognized Expert Specialist
Here's code to get you started, Sandy:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. If Me.ONTick = True Then
  3.   Me.OperatorName.Locked = True
  4.  Else
  5.   Me.OperatorName.Locked = False
  6.  End If
  7. End Sub
Expand|Select|Wrap|Line Numbers
  1. Private Sub ONTick_AfterUpdate()
  2.  If Me.ONTick = True Then
  3.   Me.OperatorName.Locked = True
  4.  Else
  5.   Me.OperatorName.Locked = False
  6.  End If
  7. End Sub
Expand|Select|Wrap|Line Numbers
  1. Private Sub ONTick_Click()
  2.  
  3. Dim PWord As String
  4.  
  5. Dim FixedPassword As String
  6. FixedPassword = "Unlock"
  7.  
  8.  If ONTick.OldValue = -1 Then
  9.   PWord = InputBox("Enter Password to Unlock Operator Name Field", "Enter Password")
  10.     If PWord = FixedPassword Then
  11.      Me.OperatorName.Locked = False
  12.      Me.ONTick = -1
  13.     Else
  14.      MsgBox "Password Incorrect!"
  15.      ONTick.Value = ONTick.OldValue
  16.      Me.OperatorName.Locked = True
  17.    End If
  18.  End If
  19. End Sub
Now this example uses a hardwired password, Unlock, as assigned to FixedPassword near the beginning of the ONTick_Click() sub. You can modify this code to take variable passwords, if you need to, possibly checking them against passwords in a tbale.

Good luck!

Linq ;0)>
Dec 14 '09 #2
greeni91
61 New Member
Hi Linq,

Thanks for the reply...I am so close to getting this now it's unreal. Thanks a Bunch.

I still have a very minor problem though and I've tried rewriting some of the code to help but this is the closest I got to perfect.

Expand|Select|Wrap|Line Numbers
  1. Private Sub ONTick_AfterUpdate()
  2.  
  3.  If Me.ONTick = True Then
  4.   Me.OperatorName.Enabled = True
  5.  Else
  6.   Me.OperatorName.Enabled = False
  7.  End If
  8.  
  9. Dim PWord As String
  10.  
  11. Dim FixedPassword As String
  12. FixedPassword = "Unlock"
  13.  
  14.  If ONTick.OldValue = -1 Then
  15.   PWord = InputBox("Enter Password to Unlock Operator Name Field", "Enter Password")
  16.     If PWord = FixedPassword Then
  17.      Me.OperatorName.Enabled = True
  18.      Me.ONTick = 0
  19.     Else
  20.      MsgBox "Password Incorrect!"
  21.      ONTick.Value = ONTick.OldValue
  22.      Me.OperatorName.Enabled = False
  23.    End If
  24.  End If
  25.  
  26. End Sub
As you can see I moved all the stuff into the after update field and I have put everything into subfrom_current as well:

Expand|Select|Wrap|Line Numbers
  1. If Me.ONTick = True Then
  2.   Me.OperatorName.Enabled = False
  3.  Else
  4.   Me.OperatorName.Enabled = True
  5.  End If
  6.  
  7. Dim PWord As String
  8.  
  9. Dim FixedPassword As String
  10. FixedPassword = "Unlock"
  11.  
  12.  If ONTick.Value = -1 Then
  13.   PWord = InputBox("Enter Password to Unlock Operator Name Field", "Enter Password")
  14.     If PWord = FixedPassword Then
  15.      Me.OperatorName.Enabled = True
  16. Else
  17.      MsgBox "Password Incorrect!"
  18.      ONTick.Value = ONTick.OldValue
  19.      Me.OperatorName.Enabled = False
  20.    End If
  21.  End If
The problem I am having is when I click on the tick box the tick appears and I input my password as wanted but when the password has been inputted the tick vanishes. What I was wanting to do is keep the tick visible so that when I untick it the box, OperatorName just locks without the password prompt.

What I have to do just know is retick the box and cancel to get the messagebox prompt to lock the field.

Any help on this would be great.

Thanks,

/Sandy
Dec 14 '09 #3
missinglinq
3,532 Recognized Expert Specialist
If you used the exact code I gave you, in the events the code was originally in, instead of trying to get clever and "consolidat e" the code into the AfterUpdate event, it would work!

And please, when posting code, hit the "Go Advanced" button at the bottom of the editing screen, select the code then hit the pound sign icon (#) to place code tags around it. It makes it much easier for us to read.

Linq ;0)>
Dec 14 '09 #4
greeni91
61 New Member
I had to change the code you gave me to tailor for my needs and I have been told countless times by people to use only one event box to stop confictions in code. One example of this is in one of my other threads.

The problem was the EXACT same when it was in the two events. I have also noticed that when I use the message box to disable the field the Tick is still visible in the box...I don't quite understand what's happening as the code looks and works okay other than this...

/Sandy
Dec 14 '09 #5
greeni91
61 New Member
I managed to fix the code to work the way I want... I was changing things in the Form_Current() section and forgot to update the changes in the AfterUpdate() section. Once these were changed the code worked no problems.... Thanks very much for all your help Missinglinq...

The code is now as follows for Form_Current():

Expand|Select|Wrap|Line Numbers
  1. If Me.ONTick = True Then
  2.   Me.OperatorName.Enabled = False
  3.  Else
  4.   Me.OperatorName.Enabled = True
  5.  End If
  6.  
  7. Dim PWord As String
  8.  
  9. Dim FixedPassword As String
  10. FixedPassword = "Unlock"
  11.  
  12.  If ONTick.Value = -1 Then
  13.   PWord = InputBox("Enter Password to Unlock Operator Name Field", "Enter Password")
  14.     If PWord = FixedPassword Then
  15.      Me.OperatorName.Enabled = True
  16. Else
  17.      MsgBox "Password Incorrect!"
  18.      Me.ONTick.Value = 0
  19.      Me.OperatorName.Enabled = False
  20.    End If
  21.  End If
and the code in the AfterUpdate field is:

Expand|Select|Wrap|Line Numbers
  1. Private Sub ONTick_AfterUpdate()
  2.  
  3.  If Me.ONTick = True Then
  4.   Me.OperatorName.Enabled = True
  5.  Else
  6.   Me.OperatorName.Enabled = False
  7.  End If
  8.  
  9. Dim PWord As String
  10.  
  11. Dim FixedPassword As String
  12. FixedPassword = "Unlock"
  13.  
  14.  If ONTick.OldValue = -1 Then
  15.   PWord = InputBox("Enter Password to Unlock Operator Name Field", "Enter Password")
  16.     If PWord = FixedPassword Then
  17.      Me.OperatorName.Enabled = True
  18.      Me.ONTick = -1
  19.     Else
  20.      MsgBox "Password Incorrect!"
  21.      Me.ONTick.Value = 0
  22.      Me.OperatorName.Enabled = False
  23.    End If
  24.  End If
  25.  
  26. End Sub
Again Thanks Very Much

/Sandy
Dec 14 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

15
4171
by: Stig Brautaset | last post by:
Hi group, I'm playing with a little generic linked list/stack library, and have a little problem with the interface of the pop() function. If I used a struct like this it would be simple: struct node { struct node *next; void *data; };
17
2200
by: Ralph | last post by:
Hi all, Recently I have tried to create a static lib using MS VC++. The following are some of the excerpt of my codes: ********* MyFirstStaticLib.c ******************* #include <stdlib.h> #include <string.h>
25
4210
by: Nicholas Parsons | last post by:
Howdy Folks, I was just playing around in IDLE at the interactive prompt and typed in dir({}) for the fun of it. I was quite surprised to see a pop method defined there. I mean is that a misnomer or what? From the literature, pop is supposed to be an operation defined for a stack data structure. A stack is defined to be an "ordered" list data structure. Dictionaries in Python have no order but are sequences. Now, does anyone know...
7
24944
by: Scott | last post by:
As said before I'm new to programming, and I need in depth explaination to understand everything the way I want to know it, call it a personality quirk ;p. With pop() you remove the last element of a list and return its value: Now I know list is a bad name, but for the sake of arguement lets assume its not a built in sequence> 'example'
13
2331
by: johnjames | last post by:
Hi! My problem is simple. I want to check for new emails (e.g. any gmail account)through PHP using POP access. I have found one such class for POP access by Manuel Lemos (http://www.phpclasses.org/browse/package/2.html) However, the above class (pop3.php) doesn't provide a method to check for new emails. It does provide a method to retrieve a message. Can someone please help me?
2
1689
by: job alerts | last post by:
Hi Im using SMTP for sending the mail.But i dont know how to receive the mail.Im sending the mail using ASP.Net C#.If some one having the codings for retrive the Email using POP3 means please send it to me Regards Kannan.M
0
992
by: avinashibs | last post by:
how to retrieve a mail using pop3 in vb.net ? i have done the authentication , but i can't retrieve a mail ????? plz help me out regarding this matter.....................
0
1134
by: Gabriel Genellina | last post by:
En Thu, 08 May 2008 09:24:37 -0300, Aspersieman <aspersieman@gmail.comescribió: Use socket.setdefaulttimeout(timeout_in_seconds) before you create the POP3 object; this value will be used by the initial connect. Once it is connected, you can set a different timeout for retrieving mail using pop.sock.settimeout(...) Note that setdefaulttimeout applies to ALL subsequent socket operations, not only using poplib....
19
3404
by: =?ISO-8859-1?Q?Nordl=F6w?= | last post by:
I am currently designing a synchronized queue used to communicate between threads. Is the code given below a good solution? Am I using mutex lock/unlock more than needed? Are there any resources out there on the Internet on how to design *thread-safe* *efficient* data- structures? /Nordlöw
3
12961
osfreak
by: osfreak | last post by:
#include<queue> #include<iostream> using namespace std; class CA { public: CA(int parm,int pri):data(parm),priority(pri) {} CA() {}
0
9794
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9642
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10778
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10496
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10538
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10210
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9319
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6951
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5788
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.