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
5 9167
Here's code to get you started, Sandy: - Private Sub Form_Current()
-
If Me.ONTick = True Then
-
Me.OperatorName.Locked = True
-
Else
-
Me.OperatorName.Locked = False
-
End If
-
End Sub
- Private Sub ONTick_AfterUpdate()
-
If Me.ONTick = True Then
-
Me.OperatorName.Locked = True
-
Else
-
Me.OperatorName.Locked = False
-
End If
-
End Sub
- Private Sub ONTick_Click()
-
-
Dim PWord As String
-
-
Dim FixedPassword As String
-
FixedPassword = "Unlock"
-
-
If ONTick.OldValue = -1 Then
-
PWord = InputBox("Enter Password to Unlock Operator Name Field", "Enter Password")
-
If PWord = FixedPassword Then
-
Me.OperatorName.Locked = False
-
Me.ONTick = -1
-
Else
-
MsgBox "Password Incorrect!"
-
ONTick.Value = ONTick.OldValue
-
Me.OperatorName.Locked = True
-
End If
-
End If
-
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)>
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. - Private Sub ONTick_AfterUpdate()
-
-
If Me.ONTick = True Then
-
Me.OperatorName.Enabled = True
-
Else
-
Me.OperatorName.Enabled = False
-
End If
-
-
Dim PWord As String
-
-
Dim FixedPassword As String
-
FixedPassword = "Unlock"
-
-
If ONTick.OldValue = -1 Then
-
PWord = InputBox("Enter Password to Unlock Operator Name Field", "Enter Password")
-
If PWord = FixedPassword Then
-
Me.OperatorName.Enabled = True
-
Me.ONTick = 0
-
Else
-
MsgBox "Password Incorrect!"
-
ONTick.Value = ONTick.OldValue
-
Me.OperatorName.Enabled = False
-
End If
-
End If
-
-
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: - If Me.ONTick = True Then
-
Me.OperatorName.Enabled = False
-
Else
-
Me.OperatorName.Enabled = True
-
End If
-
-
Dim PWord As String
-
-
Dim FixedPassword As String
-
FixedPassword = "Unlock"
-
-
If ONTick.Value = -1 Then
-
PWord = InputBox("Enter Password to Unlock Operator Name Field", "Enter Password")
-
If PWord = FixedPassword Then
-
Me.OperatorName.Enabled = True
-
Else
-
MsgBox "Password Incorrect!"
-
ONTick.Value = ONTick.OldValue
-
Me.OperatorName.Enabled = False
-
End If
-
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
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)>
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
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(): - If Me.ONTick = True Then
-
Me.OperatorName.Enabled = False
-
Else
-
Me.OperatorName.Enabled = True
-
End If
-
-
Dim PWord As String
-
-
Dim FixedPassword As String
-
FixedPassword = "Unlock"
-
-
If ONTick.Value = -1 Then
-
PWord = InputBox("Enter Password to Unlock Operator Name Field", "Enter Password")
-
If PWord = FixedPassword Then
-
Me.OperatorName.Enabled = True
-
Else
-
MsgBox "Password Incorrect!"
-
Me.ONTick.Value = 0
-
Me.OperatorName.Enabled = False
-
End If
-
End If
and the code in the AfterUpdate field is: - Private Sub ONTick_AfterUpdate()
-
-
If Me.ONTick = True Then
-
Me.OperatorName.Enabled = True
-
Else
-
Me.OperatorName.Enabled = False
-
End If
-
-
Dim PWord As String
-
-
Dim FixedPassword As String
-
FixedPassword = "Unlock"
-
-
If ONTick.OldValue = -1 Then
-
PWord = InputBox("Enter Password to Unlock Operator Name Field", "Enter Password")
-
If PWord = FixedPassword Then
-
Me.OperatorName.Enabled = True
-
Me.ONTick = -1
-
Else
-
MsgBox "Password Incorrect!"
-
Me.ONTick.Value = 0
-
Me.OperatorName.Enabled = False
-
End If
-
End If
-
-
End Sub
Again Thanks Very Much
/Sandy
Sign in to post your reply or Sign up for a free account.
Similar topics |
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;
};
|
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>
|
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...
|
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'
|
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?
| |
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
|
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.....................
|
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....
|
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
|
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()
{}
|
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...
| |
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,...
|
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...
|
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...
|
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,...
|
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...
|
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...
| |
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |