Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Is Environ("Username") okay to use ?

Posted on 2011-03-21
3
Medium Priority
?
328 Views
Last Modified: 2012-05-11
This may seem an odd question.
I have recently started using Environ("Username") to determine the log in name of the database user.

It seems to work perfectly fine.  However, I used to use a more complicated piece of code that confused me somewhat. (Unfortunately, I do not have this code to hand).

Is there any reason NOT to use Environ("Username")??

Thanks!
0
Comment
Question by:Patrick O'Dea
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1000 total points
ID: 35180323
i never have any problem using Environ("Username")

if you are ahving problem with that you can use the codes from

http://www.mvps.org/access/api/api0008.htm

Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
    "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
    strUserName = String$(254, 0)
    lngLen = 255
    lngX = apiGetUserName(strUserName, lngLen)
    If ( lngX > 0 ) Then
        fOSUserName = Left$(strUserName, lngLen - 1)
    Else
        fOSUserName = vbNullString
    End If
End Function

Open in new window

0
 
LVL 20

Assisted Solution

by:darbid73
darbid73 earned 1000 total points
ID: 35180415
Answering your question specifically

<Is there any reason NOT to use Environ("Username")??>

A user can change the Environ variables themselves.  Out of 20 computers that I have used this variable on - about 5 people have changed this variable to nothing. Or it was never inserted no idea, but the string is empty.
0
 

Author Closing Comment

by:Patrick O'Dea
ID: 35180527
Thank you both for your comprehensive answers.

Since I understand the environ("Username") code I will stick with it for the moment.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question