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 Developers    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
TempVars
Bryon Relyea 
        
2 years ago
Good day Access Gurus!!

I have been reviewing the Tech Help videos associated with splitting DBs, simple security, and TempVars. I have a 'logon button' VBA, which is stalling when trying to identify the 'Alias' to the Username.

My User_t has three fields: Username, Password, and KnownAs.

I've tried to create the caption on the Main Menu, after successful logon to read "Welcome, [Alias]" so that we see their Alias, as opposed to their Username. I have played with various versions of the following code and receive a Run-Time Error '424' Object Required. Can you please review, and see what I'm missing?

Code:

DetailsPrivate Sub LogonBtn_Click()
    
    Dim ID As Long
    Dim PW As String
        
    ID = Nz(DLookup("UserID", "User_t", "Username=""" & Username & """"), 0)
    
    If ID = 0 Then
        MsgBox "User not found"
        Quit
    End If
    
    PW = Nz(DLookup("Password", "User_t", "UserID=" & ID), "")
    
    
    If PW <> Password Then
        MsgBox "Incorrect Password"
        Quit
    End If
    
    If IsNull(Username) Then
        MsgBox "Invalid Username"
        Exit Sub
    End If
    
    If PW = Password Then
        
        DoCmd.OpenForm "Dashboard"
        DoCmd.Maximize
        TempVars("Username") = Username.Value
        TempVars("Alias") = KnownAs.Value
        
        DoCmd.Close acForm, Me.Name, acSaveYes
      
    Else
        
        MsgBox "Invalid Logon"
    
    End If

End Sub

___________________________________________________________________________

My On Load Code:

   DashboardLabel.Caption = "Welcome, " & TempVars("Alias")

________________________________________________________________

I appreciate the help!!

- Bryon R.
Alex Hedley  @Reply  
           
2 years ago
Do you need the .Value?
Kevin Robertson  @Reply  
          
2 years ago
Set the TempVars BEFORE you open the form.
John Davy  @Reply  
         
2 years ago
Hi Byron
Kevin is correct! I usually pick up this info on the Logon Form on Close, then I can display it as needed.

John
Bryon Relyea OP  @Reply  
        
2 years ago
Hello, Alex, Kevin, and John.

Thank you for the quick replies.  The setting of the TempVars is on the logon button. I'll definitely try with them being declared before form open. I will let you know the results.

Thank you, again!!
Bryon Relyea OP  @Reply  
        
2 years ago
SUCCESS!! -
Gentlemen - thank you very much for your feedback. Took both pieces of feedback; moved the TempVars before form open, and also took away '.Value' from Alias declaration. Works like a charm!

Thank you, again!
Bryon Relyea OP  @Reply  
        
2 years ago
Hello, gentlemen -

Sorry to bother you.....again. I tried to enhance my password change messaging, and am now getting an error on my Update commands. I either receive a Syntax error, or a 'Parameter missing' error.

CODE:

CurrentDb.Execute "UPDATE User_t" & _
    "SET Password=""" & Password & """, DtChanged=#" & Date & "# " & _
            "WHERE Username=""" & TempVars("Username") & """"
______

Table: User_t
Fields: Username, Password, DtChanged, Alias
TempVars are declared on logon form, before opening the Change Password form and process.  I cannot see any errors.

I appreciate the review!
Alex Hedley  @Reply  
           
2 years ago
Check for spaces
Bryon Relyea OP  @Reply  
        
2 years ago
Man....I looked at this over the weekend, and all morning. Your tip was correct, once again! I needed a space on the first line, after my form name.

Thank you, Alex!
Alex Hedley  @Reply  
           
2 years ago
One habit to get into is creating variables to hold your SQL string, then you've got it available to Debug.Print, add a Watch or MsgBox it so you can check the output easier.
Bryon Relyea OP  @Reply  
        
2 years ago
@Alex & @Kevin - is each of your PayPal accounts in GBP?  I want to make sure I'm grabbing the correct accounts.
@John - I don't see a tip jar set-up for you....
Sami Shamma  @Reply  
             
2 years ago
Hi Bryon

you should be able to pay both of these fine gentlemen on PayPal without worrying about their currency setting.  Just remember to select Family and friends so they do not lose out.
Bryon Relyea OP  @Reply  
        
2 years ago
oh, shoot...i think I picked the other when I sent to Kevin. And I only asked the question to make sure I got the correct accounts.

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

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/6/2026 5:15:18 AM. PLT: 1s