473,485 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Password Form

Slaxer13
106 New Member
Hi ppl.
I did a form called frmPassword. It opens when someone clicks the delete button. That form has two textoboxes and two buttons. txtCod which is invisible and where the password is stored. txtPassword where the user enters the password. btnOk button to confirm the password. btnCancel to cancel and return to the previous form without deleting anything.

The question is: what is the code that i must use on the btnOk? I want it to check if the txtPassword has the same value as in the txtCod. If they are the same it triggers the delete button onclick event. if they are not the same i want it to display a msgbox sayng "error, wrong pass". the msgbox i know how to do but i don't know how to trigger the delete button...

Help appreciated, Slaxer13
Jun 27 '14 #1
14 1630
twinnyfo
3,653 Recognized Expert Moderator Specialist
slaxer,

Remember, your delete button triggers the password authentication. That is the key. Create another Public Function or Sub in the Main form which actually deletes the record. Could be as simple as:

Expand|Select|Wrap|Line Numbers
  1. Public Sub DeleteTheRecord()
  2.     DoCmd.RunCommand acCmdDeleteRecord
  3. End Sub
Then, in your Password Form, once the Password is validated, call the function:

Expand|Select|Wrap|Line Numbers
  1. Forms!FormName.DeleteTheRecord
Trying to remember off the top of my head if I nee to add "Form." before the delete. But one or the other should work.

Just make sure the Function/Sub is Public, otherwise it won't work.
Jun 28 '14 #2
NeoPa
32,556 Recognized Expert Moderator MVP
That's a perfect answer. However - consider an alternative approach which should make your job easier.
  1. In your cmdDelete code have something like :
    Expand|Select|Wrap|Line Numbers
    1. Private Sub cmdDelete_Click()
    2.     If Not ValidatePassword() Then Exit Sub
    3.     'Code to do whatever deletion you want here.
    4. End Sub
  2. Your ValidatePassword() procedure would be a Public function defined in a standard module. It would incorporate the checking logic you already have then return a Boolean value of True if the test was passed and False if it weren't.
  3. Your frmPassword form should be set up with a hidden CheckBox which defaults to False but is set to True by the txtPassword_AfterUpdate() event handler so that the code that opens frmPassword knows it can proceed :
    Expand|Select|Wrap|Line Numbers
    1. Private Sub txtPassword_AfterUpdate()
    2.     Me.chkDone = True
    3. End Sub
  4. Expand|Select|Wrap|Line Numbers
    1. Public Function ValidatePassword() As Boolean
    2.     Dim frmPW As Form_frmPassword
    3.  
    4.     Call DoCmd.OpenForm("frmPassword")
    5.     With Forms("frmPassword")
    6.         Do Until .chkDone
    7.             DoEvents
    8.         Loop
    9.         ValidatePassword = (.txtPassword = .txtCOD)
    10.         Call .Close(ObjectType:=acForm _
    11.                   , ObjectName:="frmPassword"
    12.                   , Save:=acSaveNo)
    13.     End With
    14. End Function
NB. The code here is all air-code so may need fixing in places, but should illustrate the idea at least.
Jun 28 '14 #3
burrina
6 New Member
Easy Way! Using OnOpenEvent. Of course, you can change the Msg and Password to your liking.

Expand|Select|Wrap|Line Numbers
  1. Cancel = (InputBox("Please Enter a Password ?") <> "authorized")
HTH
Jun 29 '14 #4
NeoPa
32,556 Recognized Expert Moderator MVP
I'm not sure you quite understand the question. Certainly that doesn't represent a solution I'm afraid.
Jun 30 '14 #5
burrina
6 New Member
This is not my thread. However, after looking back at it, yes that is true. I would have a command button that opens another password form that asks for confirmation.
Expand|Select|Wrap|Line Numbers
  1.  
  2. If IsNull(Forms!frmPassword!Text0) Then               'No Blank passwords allowed
  3.     MsgBox "You cannot enter a blank Password. Try again."
  4.     Me!Text0.SetFocus
  5. Else
  6.     'No More Than 3 Attempts Allowed
  7.     If Me.LIChk > 2 Then
  8.         MsgBox "Only three Password entry attempts allowed.", vbCritical + vbOKOnly, "Oops!"
  9.             DoCmd.quit
  10.  
  11.         ElseIf Forms!frmPassword!Text0 = "password" Then    'Change To Your Password.
  12.             DoCmd.SetWarnings False
  13.            If MsgBox("Do you wish to delete this record?", vbYesNo, "Delete Confirmation") = vbYes Then
  14.    If MsgBox("Are you SURE you want to delete this record?" & vbCrLf & _
  15.     "This will permanently delete the record.", vbYesNo, "2nd Delete Confirmation") = vbYes Then
  16.     DoCmd.SelectObject acForm, "frmOne" 'Change To Your Form Name.
  17.          DoCmd.RunCommand acCmdDeleteRecord
  18.          DoCmd.SetWarnings True
  19.          DoCmd.Close acForm, Me.Name
  20.  
  21.  
  22.         End If
  23.             End If
  24.                 End If
  25.                     End If
EDITED: Sorry for not understanding the 1st time.
Jun 30 '14 #6
Slaxer13
106 New Member
Good morning ppl. How are you?
NeoPa the validatepassword() function where should i put it? frmPassword or on the form where the delete button is?

Thanks for all the help (NeoPa and the others) ;)
Cheers, Slaxer13
Jun 30 '14 #7
Slaxer13
106 New Member
twinnyfo:
Expand|Select|Wrap|Line Numbers
  1. Forms!FormName.DeleteTheRecord
It says the "command or action "deleterecord" is not available at the moment"

NeoPa:
Expand|Select|Wrap|Line Numbers
  1. Call .Close(ObjectType:=acForm _
  2.                        , ObjectName:="frmPassword" _
  3.                        , Save:=acSaveNo)
it says "application-defined or object-defined error"
Jun 30 '14 #8
Slaxer13
106 New Member
twinnyfo: it was not:
Expand|Select|Wrap|Line Numbers
  1. 1.Forms!FormName.DeleteTheRecord
i used:
Expand|Select|Wrap|Line Numbers
  1. Form_frmUtente.DeleteTheRecord
Jun 30 '14 #9
NeoPa
32,556 Recognized Expert Moderator MVP
Slaxer:
NeoPa the validatepassword() function where should i put it? frmPassword or on the form where the delete button is?
That depends. If you want it to be available universally then put it in its own separate module (or at least somewhere in a Standard module). If it's only ever going to be used from your first (calling) form then it can go in that form's module.
Slaxer:
it says "application-defined or object-defined error"
Apologies. It was air-code and this bit I got wrong. It should say :
Expand|Select|Wrap|Line Numbers
  1.         Call DoCmd.Close(ObjectType:=acForm _
  2.                        , ObjectName:="frmPassword"
  3.                        , Save:=acSaveNo)
Jun 30 '14 #10
Slaxer13
106 New Member
Thanks NeoPa. I managed to put twinnyfo's idea to work while I was waiting for your response. His idea works fine but I'll try yours and see which fits best ;)

Cheers, Slaxer13
Jun 30 '14 #11
Slaxer13
106 New Member
I managed to put the two ideas to work but, from my point of view, seems that twinnyfo's idea is more simple although they are both correct. I will mark twinnyfo's idea since I used it but for searches this thread know that both ideas are perfectly usable. As for burrina's answer I have not tried it as for me I find it a bit confusing (i am a beginner so the simpler the better and since there are one or two commands I am not familiarized with...), but I am not saying is wrong ;)

Cheers, Slaxer13
Jun 30 '14 #12
NeoPa
32,556 Recognized Expert Moderator MVP
It's a pleasure working with someone who is polite to all and takes the time to explain where they're at.

Welcome to Bytes!
Jun 30 '14 #13
Slaxer13
106 New Member
Thanks NeoPa. I just am what people are to me ;)
Jul 1 '14 #14
NeoPa
32,556 Recognized Expert Moderator MVP
I'll try to avoid being rude to you then :-D

PS. I understand you really. Just having a joke :-)
Jul 1 '14 #15

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

Similar topics

0
1360
by: Doug Bell | last post by:
Hi I am having difficulty getting a password form to work correctly. I am using VB.Net. The required functionality is to allow a change to a setting but when a save button is clicked a password...
1
13050
by: william cline | last post by:
Hi, I am a beginner and below I have code for a long in form. My goal is for the form to read a file of a list of users and thier passwords ....compare the text box inputs to the file and either...
2
3780
by: Chuckles | last post by:
I am building a simple access database for a small home business. I have a table containing userid, password, and rights(either admin or regular) which will simply stop someone from clicking on...
5
17557
by: Tony | last post by:
Please help, I've scoured the web but cannot find an answer to this! I want to use WebRequest to get the contents of a web page. The trouble is, the page require you to go to a login page (using...
4
1574
by: mforema | last post by:
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...
1
2406
by: Eric | last post by:
Hi, I have a form that should be restricted to some users. I want to create a password form that requires a password to access that form. Can someone help guide me on how to create one? Thanks!
1
2600
by: dan.cawthorne | last post by:
Hi all, Need Some Help With A Simple Password Form What a I Have Is Single Field Table, With One Record In It The Field is Called table is also called "Password" which ive created a form...
0
792
by: martin lanny | last post by:
Is there any way to monitor open IE/Firefox windows/tabs from VB.NET/CSHARP and display a small button next to all username/password form fields? Same thing as Skype does with their software...
2
3051
by: ma.giorgi | last post by:
Hi Everybody! I have the following problem: from the application mainForm the user can do several operation Some of them are password protected (the password is a code that change everytime on...
7
4378
by: Jesse Jones | last post by:
Any ideas on how to send info from one form into another domain or how to write a default value for a new user's password with a formula? Here's what I'm trying to do: design my database so that...
0
7090
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,...
0
6960
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...
0
7116
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,...
1
6825
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...
0
7275
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...
0
4551
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...
0
3058
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...
0
3063
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1376
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 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.