473,414 Members | 1,605 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,414 software developers and data experts.

I want to use "if then else" function

Expand|Select|Wrap|Line Numbers
  1. If [Loginpassword]=[password] then
  2. Docmd.openform"form1"
  3. else
  4. MsgBox(wrong login).
the first part is not working,not open the form,what is wrong?
Jun 4 '17 #1
2 839
PhilOfWalton
1,430 Expert 1GB
You're a bit short of information.
I assume the LoginPassword is typed in and the code you are trying to run occurs on the after update of that field.

Where does the Password data come from?

Here is some code I use, but there is a table of users and their passwords, and the person trying to log in has to select their name first and hence their UserID

This code is a modification of the code I use, so is not guaranteed.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Option Compare Database
  3. Option Explicit
  4.  
  5.     Dim Tries As Integer
  6.  
  7.     Private Declare PtrSafe Function GetKeyState Lib "user32" _
  8.         (ByVal nVirtKey As Long) As Integer
  9.  
  10. Function GetCapslock() As Boolean
  11.     'Return the CapsLock Value
  12.  
  13.     GetCapslock = CBool(GetKeyState(vbKeyCapital) And 1)
  14.  
  15. End Function
  16.  
  17. Private Sub LoginPassword_AfterUpdate()
  18.  
  19.     Dim UserPass As String
  20.  
  21.     If Nz(LoginPassword) = "" Then
  22.         Exit Sub
  23.     End If
  24.  
  25.     UserPass = ELookup("LoginPassword", "Users", "UserID = " & UserID)
  26.  
  27.     If StrComp(UserPass, LoginPassword, vbBinaryCompare) = 0 Then
  28.         Docmd.openform "form1"                         ' Open the menu
  29.     Tries = 0
  30.     Else
  31.         If GetCapslock() = True Then
  32.            Msgbox "The Caps Lock is on", VbInformation
  33.         Else
  34.             Mshbox "Wrong Password. - Please re-enter", VbInformation
  35.         End If
  36.         Tries = Tries + 1
  37.         If Tries > 3 then
  38.             DoCmd.Quit
  39.         End If
  40.    End If
  41.  
  42.  
This password check is case sensitive and gives a warning if Caps lock is on. It is also up to you what you want to do after 3 unsuccessful tries.

Phil
Jun 4 '17 #2
NeoPa
32,556 Expert Mod 16PB
Please read How to ask "good" questions -- READ BEFORE SUBMITTING A QUESTION!.

Your question looks like you've done no preparation for it at all.
Jun 4 '17 #3

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

Similar topics

7
by: vegetax | last post by:
I i need a decorator that adds a local variable in the function it decorates, probably related with nested scopes, for example: def dec(func): def wrapper(obj = None): if not obj : obj = Obj()...
8
by: Amit | last post by:
Hello all. If I want to use an object both as a Functor and also, if I pass a function pointer, how can it be done ? For instance, I have something like this template< typename Iter, typename...
6
by: Stuart McGraw | last post by:
I am looking for a VBA "format" or "template" function, that is, a function that takes a format string and a varying number of arguments, and substitutes the argument values into the format string...
4
by: veereshai | last post by:
i want to copy the functions from my source file into a new file...and convert each function into a new object file by compiling it. now, i want to invoke the function using the object file i have...
2
by: Mark | last post by:
Hy. How Can I make Function which when I call this function e.g. Call Star(10,20) And I want that this function receive me any value. *** *** Sample Private sub Button_Click Call Start(10,50)...
3
by: drummond.ian | last post by:
Hello Everyone, This problem's been causing me a lot of trouble and I'm hoping somebody can help me out!! I have a dialog-based MFC application in visual studio 2003. I want to call a...
2
by: Julien | last post by:
Hello all, I would like to do something like: def called(arg) if arg==True: !!magic!!caller.return 1 def caller(arg) called(arg)
12
by: Bryan Parkoff | last post by:
I write my large project in C++ source code. My C++ source code contains approximate four thousand small functions. Most of them are inline. I define variables and functions in the global scope....
2
by: beso2ooo | last post by:
File f = new File("C:\\TEST"); try{ if(f.exists()==false){ f.mkdir(); System.out.println("Directory Created"); } else{ ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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,...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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 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.