Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > Forums > Developers
Back to Access Developer Forum    Comments List
Upload Images   Link   Email  
Logon Form
Daniel Golden 
      
39 days ago
I followed the instructions Richard provided in creating a logon form in the TechHelp video series for User Level Security. I have added to it with a Title combo box which the users select their given job title from the list. All boxes send the data to a TempVar for use elsewhere in the database.

I am now trying to update this form so that if a user is not current, it pops a message box up saying "Inactive User" and then quits the database. In the underlying UserT, I have added a yes/no field for "Current" and in the VBA for the Logon button it looks like the included code. It is not working in the fact that when I click the Logon button it comes up with Run-time error '3075'" Syntax error in string query expression 'Current=Current'".

I just want the button to check the UserT if a user is still current and if not tell the user so and then quit the database.

DetailsPrivate Sub LogonBtn_Click()

    Dim ID As Long, PW As String, JT As Long, Current As String
    
    ID = Nz(DLookup("UserID", "UserT", "Username=""" & Username & """"), 0)
    If ID = 0 Then
        MsgBox "User not found"
        Quit
        
    End If
    
    PW = Nz(DLookup("Password", "UserT", "UserID=" & ID), "")
    If PW <> Password Then
        MsgBox "Incorrect Password"
        Quit
    
    End If
    
    JT = Nz(DLookup("Job_Title", "UserT", "Job_Title=""" & "Job_Title" & """"), 0)
    
    Current = Nz(DLookup("Current", "UserT", "Current=" & "Current" & """"), 0)
    If Current <> True Then
        MsgBox "Inactive User"
        Quit
        
    End If

    TempVars("Username") = Username.Value
    TempVars("UserID") = ID
    TempVars("Title") = Job_Title.Value
    DoCmd.OpenForm "Main Menu"
    DoCmd.Close acForm, Me.Name, acSaveYes
    
End Sub
Kevin Robertson 
          
39 days ago
Use the ID that you have already looked up.

    Current = DLookup("Current", "UserT", "UserID=" & ID)
    If Not Current Then
        MsgBox "Inactive User"
        Quit  
    End If


Note: you don't need the Nz function when looking up a Yes/No field as it won't be Null. It will be either True or False.
Daniel Golden OP 
      
39 days ago
Thanks Kevin! Worked perfectly.

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

 
 
 

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 2025 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 2/13/2025 1:48:20 AM. PLT: 0s