Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Security Password Solution
Robert Lilly 
   
16 years ago
Richard, I’m the old man with the memory problems. I copied this and used in a program that I put together for a local volunteer group that gives out the Flu shots, back when you first posted it. Now I did go back and take the course again, even down loaded your complete data base, and can’t figure out how to resolve the problem. Can you help me with this? Or post it and see if someone of your students can resolve my delimer?
When I start the program, the Logon Form is displayed, typing anything into the Username or the Password Box, and then clicking on the Login Box, will cause the Message Box to display “Invalid Logon”. Clicking on the “OK” button will close the LogonF and then you have unrestricted access to the program. Is there anything I can add to the VBA code to resolve this problem?

Private Sub Command16_Click()
    If IsNull(txtUsername) Then
        MsgBox "Invalid username"
        Exit Sub
    End If
    If IsNull(txtPassword) Then
        MsgBox "Invalid password"
        Exit Sub
    End If
    
    Dim X As Long
    X = Nz(DLookup("UserID", "UserT", "Username='" & txtUsername & "' And Password='" & txtPassword & "'"))
      
    If X > 0 Then
        ' We have a valid user
        DoCmd.OpenForm "MainMenuF"
        DoCmd.Close acForm, "LoginF"
    Else
        MsgBox "Invalid Logon"
    End If
           DoCmd.Close acForm, "LoginF"
End Sub



Reply from Richard Rost:

I don't see anything wrong with your code. Maybe force a zero into your NZ function if it's null:

X = NZ(DLOOKUP(same),0)

If you just close the login form without doing anything else, you are going to just leave the user at the database window (which I assume you've hidden). You could issue an "End" command or a "DoCmd.Quit" to shut the database down. Further in the seminar I go over more steps to lock down the rest of your database.

But I don't see anything glaringly wrong with your code - but it is early (for me) and I'm only on my first cup of coffee. :)

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 7/3/2026 3:10:57 AM. PLT: 1s