473,320 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

adding an attempt onto my password

hi guys,
i want to add attempt onto my password so that the person login in only has a limited amount of attempt they can try to enter the corret password but I have no idea how to do it can someone guide me on how to do it.
this code works fine if the person makes a mistake. (It does not let the person log in but it does not give the person another chance.)

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form_Open(Cancel As Integer)
  3.  
  4. Dim password As String
  5.  
  6. password = InputBox("Please enter the correct password.")
  7.  
  8. If password = "Rodney" Then
  9. MsgBox "Welcome to the Booking System on Nottingham Academy"
  10.  
  11. Else
  12.  
  13. MsgBox "Incorrect. Please try again"
  14.  
  15. DoCmd.Close
  16. DoCmd.Close acForm, "HomePage"
  17.  
  18. End If
  19.  
  20. End Sub
  21.  
Apr 19 '17 #1
1 1037
Luk3r
300 256MB
You have a couple of solutions, but the best solutions are either a Do..While loop or a Do..Until loop. Below are examples of how you would use them.

Do..Until
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.     Dim countLoginTries As Integer = 0
  3.     Dim totalLoginTries As Integer = 3
  4.  
  5.     Do
  6.         Dim password As String
  7.  
  8.         password = InputBox("Please enter the correct password."
  9.  
  10.         If password = "Rodney" Then
  11.             MsgBox "Welcome to the Booking System on Nottingham Academy"
  12.         Else
  13.             MsgBox "Incorrect.  Please try again."
  14.             DoCmd.Close
  15.             DoCmd.Close acForm, "HomePage"
  16.         End If
  17.  
  18.     Loop Until countLoginTries > totalLoginTries
  19. End Sub
Do..While
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.     Dim countLoginTries As Integer = 0
  3.     Dim totalLoginTries As Integer = 3
  4.  
  5.     Do While countLoginTries <= totalLoginTries
  6.         Dim password As String
  7.  
  8.         password = InputBox("Please enter the correct password."
  9.  
  10.         If password = "Rodney" Then
  11.             MsgBox "Welcome to the Booking System on Nottingham Academy"
  12.         Else
  13.             MsgBox "Incorrect.  Please try again."
  14.             DoCmd.Close
  15.             DoCmd.Close acForm, "HomePage"
  16.         End If
  17.  
  18.     Loop
  19. End Sub
Apr 20 '17 #2

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

Similar topics

0
by: John | last post by:
Hi, I'm using mysql-server-3.23.58-4 on a Linux (Fedora 1) machine, and I'm new to databases/MySQL. After reading the security section of the manual from http://dev.mysql.com, I added...
0
by: George Chorny | last post by:
Hello, I'm sure may are familiar with the following error. Getting it while trying to change the password from w/in the db2 client? Running IBM DB 8.2 Fixpack8 SLES8/2.4 moving to SLES9/2.6.5 ...
3
by: MotorcycleIke | last post by:
I tried using WebRequest, but I am unable to simply redirect to an external aspx site and supply the userid and password and press their login button. Can anyone help? Thanks, I've spent a...
8
by: Noel Volin | last post by:
Anyone who can help here is much appreciated. I am trying to programmatically log onto a website. I am using the code provided in VS for the AuthenticationManager Class example (...
4
by: James | last post by:
I succesfully pass username , domain and password via this function (taken from MSDN) Private Declare Auto Function LogonUser Lib "advapi32.dll" (ByVal lpszUsername As , _ ByVal lpszDomain As...
1
by: kevin.vaughan | last post by:
Hello Everyone, Is it possible to authenticate the windows password through Active Directory? If so, how would this be done. I have a login screen in my application and am trying to set it up...
30
by: diane | last post by:
I've got an application running with table-based security: i capture the user's windows login with fOsusername, then have them enter a password checked against their username/login in my own table....
2
by: Ken Fine | last post by:
I want to add the security question and answer security feature to the ChangePassword control. I am aware that this functionality is built into the PasswordRecovery tool. I have implemented the...
3
by: vbbeginer | last post by:
I have a log in form with max attempts of 3 then the program will automatically closed, but i want to find the code to block the user to log in with a time interval..Im using VB 2008(VB.net) and MS...
0
by: mehmatt | last post by:
hey all... i have 1 script which has similarities forums but more like urbandictionary... anyway i need some codes to name hyperlinks auto which are typed by users. shortly, i want the script to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

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.