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
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: - Public Sub DeleteTheRecord()
-
DoCmd.RunCommand acCmdDeleteRecord
-
End Sub
Then, in your Password Form, once the Password is validated, call the function: - 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.
NeoPa 32,556
Recognized Expert Moderator MVP
That's a perfect answer. However - consider an alternative approach which should make your job easier. - In your cmdDelete code have something like :
- Private Sub cmdDelete_Click()
-
If Not ValidatePassword() Then Exit Sub
-
'Code to do whatever deletion you want here.
-
End Sub
- 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.
- 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 :
- Private Sub txtPassword_AfterUpdate()
-
Me.chkDone = True
-
End Sub
-
- Public Function ValidatePassword() As Boolean
-
Dim frmPW As Form_frmPassword
-
-
Call DoCmd.OpenForm("frmPassword")
-
With Forms("frmPassword")
-
Do Until .chkDone
-
DoEvents
-
Loop
-
ValidatePassword = (.txtPassword = .txtCOD)
-
Call .Close(ObjectType:=acForm _
-
, ObjectName:="frmPassword"
-
, Save:=acSaveNo)
-
End With
-
End Function
NB. The code here is all air-code so may need fixing in places, but should illustrate the idea at least.
Easy Way! Using OnOpenEvent. Of course, you can change the Msg and Password to your liking. - Cancel = (InputBox("Please Enter a Password ?") <> "authorized")
HTH
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.
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. -
-
If IsNull(Forms!frmPassword!Text0) Then 'No Blank passwords allowed
-
MsgBox "You cannot enter a blank Password. Try again."
-
Me!Text0.SetFocus
-
Else
-
'No More Than 3 Attempts Allowed
-
If Me.LIChk > 2 Then
-
MsgBox "Only three Password entry attempts allowed.", vbCritical + vbOKOnly, "Oops!"
-
DoCmd.quit
-
-
ElseIf Forms!frmPassword!Text0 = "password" Then 'Change To Your Password.
-
DoCmd.SetWarnings False
-
If MsgBox("Do you wish to delete this record?", vbYesNo, "Delete Confirmation") = vbYes Then
-
If MsgBox("Are you SURE you want to delete this record?" & vbCrLf & _
-
"This will permanently delete the record.", vbYesNo, "2nd Delete Confirmation") = vbYes Then
-
DoCmd.SelectObject acForm, "frmOne" 'Change To Your Form Name.
-
DoCmd.RunCommand acCmdDeleteRecord
-
DoCmd.SetWarnings True
-
DoCmd.Close acForm, Me.Name
-
-
-
End If
-
End If
-
End If
-
End If
EDITED: Sorry for not understanding the 1st time.
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
twinnyfo: - Forms!FormName.DeleteTheRecord
It says the "command or action "deleterecord" is not available at the moment"
NeoPa: - Call .Close(ObjectType:=acForm _
-
, ObjectName:="frmPassword" _
-
, Save:=acSaveNo)
it says "application-defined or object-defined error"
twinnyfo: it was not: - 1.Forms!FormName.DeleteTheRecord
i used: - Form_frmUtente.DeleteTheRecord
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 : - Call DoCmd.Close(ObjectType:=acForm _
-
, ObjectName:="frmPassword"
-
, Save:=acSaveNo)
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
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
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!
Thanks NeoPa. I just am what people are to me ;)
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 :-)
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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...
|
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...
| |
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!
|
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...
|
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...
|
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...
|
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...
|
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: 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,...
|
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: 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...
|
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...
|
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 ...
| |