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 Developer Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
GetSettings Function
Kevin Robertson 
          
3 years ago
Here's a simple function to get any setting from your settings table.

Place the function in a Module.
Public Function GetSettings(SettingName As String) As Variant

     TempVars(SettingName) = Nz(DLookup(SettingName, "SettingsT"), "")
     GetSettings = TempVars(SettingName)
    
End Function


Then call it from any where in the database.
lblHeader.Caption = GetSettings("DatabaseName")
lblCopyright.Caption = GetSettings("Copyright")


@Adam also loving TempVars.
Kevin Robertson OP  @Reply  
          
3 years ago
Just added a Sub Routine to my module so the settings on the Main Menu update automatically when the settings form is closed. Also, my copyright statement is now dynamic and will update to a range of years with the initial year being stored in the Settings table.

Public Sub SetSettings()

    Dim copyYearStart As Long, copyYearEnd As Long, copyYearRange As String
    
    copyYearStart = GetSettings("CopyrightYear")
    copyYearEnd = Year(Date)
    copyYearRange = IIf(copyYearStart = copyYearEnd, copyYearStart, copyYearStart & "-" & copyYearEnd)
    
    If CurrentProject.AllForms("MainMenuF").IsLoaded Then
        Forms!MainMenuF!lblHeader.Caption = GetSettings("DatabaseName")
        Forms!MainMenuF!lblCopyright.Caption = Replace(GetSettings("Copyright"), "{Year}", copyYearRange)
    End If
    
End Sub
Sandra Truax  @Reply  
         
3 years ago
Thanks for sharing, Kevin.  I don't have a clue what you are talking about but plan on playing with this and trying to figure it out. :)
Kevin Robertson OP  @Reply  
          
3 years ago
Thanks Sandra. The SetSettings sub above will set the copyright on the Main Menu form only. I have since needed it on another form (my splash screen) so I made it a function instead.

Public Function GetCopyright() As String

    Dim copyYearStart As Long, copyYearEnd As Long, copyYearRange As String
    
    If Not IsNull(GetSettings("CopyrightYear")) And GetSettings("CopyrightYear") <> "" Then
        copyYearStart = GetSettings("CopyrightYear")
        copyYearEnd = Year(Date)
        copyYearRange = IIf(copyYearStart = copyYearEnd, copyYearStart, copyYearStart & "-" & copyYearEnd)
    End If
    
    GetCopyright = Replace(GetSettings("Copyright"), "{Year}", copyYearRange)
    
End Function


This function relies on the GetSettings function and the initial copyright year to be a field in the Settings table. You can, of course, send the CopyrightYear to the function.
Sandra Truax  @Reply  
         
3 years ago
Thanks Kevin, for explaining. I understand now. :)

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer 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: 5/2/2026 8:53:46 AM. PLT: 1s