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 
Table GetUserName with VBA Unknown Function
Monica Davis 
     
10 months ago
I have three databases.  In 2 of them that I have had a few years this works with no issues.  This week I have been trying to add this to a table in a different database.  Keep getting error "unknown function."  All 3 databases are on the same network share drive.  I have compared the three and see no difference.  

VBA Module (modUser):
Option Compare Database
Option Explicit
Function GetUserName() As String
     GetUSerName = Environ("UserName")
End Function

When test function in Module it returns my username.

In my table tblINterpreter have field InterpreterCreatedBy as text 100.  In the Default Value have =GetUserName().
Table because team imports data multiple times daily.  They save file in certain folder, open form, click import. Goal is to see at table level who appended the row.

Any idea why not working when trying to add to 3rd database?  Any suggestion for alternative way of table row defaulting value to username?
Raymond Spornhauer  @Reply  
          
10 months ago
Monica

Add "Public" in front:

Public Function GetUserName() As String

-Raymond
Monica Davis OP  @Reply  
     
10 months ago
Posting incase other read this forum in future:
2 changes made that got it working:
1) Added Public to start of code.  Yep - with all my back and forth removed the word Public.  
2) Updated UserName to USERNAME.  For some reason, all caps was needed for it to work.
Richard Rost  @Reply  
           
10 months ago
1. Awesome.
2. That's weird. Access isn't case sensitive unless you have Option Compare Binary at the top of the module.

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: 5/6/2026 1:27:00 PM. PLT: 1s