[AccessD] an ACCESS query

Ryan W wrwehler at gmail.com
Tue Mar 12 11:40:32 CDT 2019


What about just

Environ("Username") ?



On Tue, Mar 12, 2019 at 11:39 AM Bob Walsh <BWalsh at healthinsight.org> wrote:

> Something like this?
>
> Declare PtrSafe 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
>
> From: AccessD <accessd-bounces at databaseadvisors.com> On Behalf Of John W.
> Clark
> Sent: Tuesday, March 12, 2019 9:36 AM
> To: Access Developers discussion and problem solving <
> accessd at databaseadvisors.com>
> Subject: Re: [AccessD] an ACCESS query
>
> [Attn: This is an external email.]
>
> I haven't been out here in quite a while, but I'm hoping someone can save
> me. I seem to have forgotten some things and I need to grab a user's Active
> Directory login ID and put it in a record.
>
> I actually haven't programmed anything in quite a while. I've been playing
> with VoIP phones and email lately and haven't needed to work with MS Access
> in a very long time. I still lurk every now and then and read the posts,
> but I haven't needed to use it.
>
> I'm praying someone has some code I can use to do this quick. I was trying
> to use a couple of things, like:
>
>
> Dim strUser as String
> strUser = ActiveDirectory.User()
> MsgBox "Welcome back, " & strUser
>
> but I get nothing...no errors, just nothing. I've tried variations and
> some other code I've found as well.
>
> Is the "ActiveDirectory" code above native or should I be invoking
> something to make it work?
>
>
> Notice: This electronic transmission is intended for the sole use of the
> individual or entity to which it is addressed and may contain confidential,
> privileged or otherwise legally protected information. If you are not the
> intended recipient, or if you believe you are not the intended recipient,
> you are hereby notified that any use, disclosure, copying, distribution, or
> the taking of any action in reliance on the contents of this information,
> is strictly prohibited. Niagara County is not responsible for the content
> of any external hyperlink referenced in this email or any email. IF YOU
> HAVE RECEIVED THIS TRANSMISSION IN ERROR, PLEASE NOTIFY THE SENDER
> IMMEDIATELY BY EMAIL AND DELETE THE ORIGINAL MESSAGE ALONG WITH ANY PAPER
> OR ELECTRONIC COPIES. Thank you for your cooperation.
> --
> AccessD mailing list
> AccessD at databaseadvisors.com<mailto:AccessD at databaseadvisors.com>
> http://databaseadvisors.com/mailman/listinfo/accessd<
> http://databaseadvisors.com/mailman/listinfo/accessd>
> Website: http://www.databaseadvisors.com<http://www.databaseadvisors.com>
>
> ________________________________
> HealthInsight is a private, nonprofit, community-based organization
> dedicated to improving health and health care, with offices in four western
> states: Nevada, New Mexico, Oregon and Utah. HealthInsight also has
> operations in Seattle, Wash., and Glendale, Calif., supporting End-Stage
> Renal Disease Networks in the Western United States. The information and
> any materials included in this transmission may contain confidential
> information from HealthInsight. The information is intended for use by the
> person named on this transmittal. If you are not the intended recipient, be
> aware that any disclosure, copying, distribution, or use of the contents of
> this transmission is prohibited. If you have received this message in
> error, please inform the sender and delete all copies.
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


More information about the AccessD mailing list