Code Snippets
In all the times I have spent participating in forum discussions about all sorts of users' questions, I have learnt a great deal from all the participants.
I have decided to post some of the sample codes that I found users were asking for almost all the time to help me keep them in one place and to make it easier for me to share them again and again.
Hope you find them useful.
Get Network Username
Here's another gem from fellow MVP, Brent Spaulding (datAdrenaline). It returns the network username of the currently logged in user without using API. I just wrapped his function inside a self-healing property (an idea that I learned from fellow MVP, Jack Leach).
Option Compare Database
Option Explicit
'Module name: modUser
Private pUser As String
Public Property Get Username() As String
'Uses a self-healing property to return the network username
'Thanks to Brent Spaulding (datAdrenaline), MVP for the function
' to retrieve the username without using API
'Thanks to Jack Leach (jleach), MVP for the idea on self-healing propeties
'Source: http://www.accessmvp.com/thedbguy
'Usage: Me.ControlName = modUser.Username
If pUser > "" Then
'Just return the existing username
Else
'Get username
pUser = CreateObject("wscript.network").Username
End If
Username = pUser
End Property
Contents
- Generate GUIDs
- Backup and Compact BE
- Get E-mail Address from AD
- Get Network Username
- Leigh's Generic Recordset
- Trim Inner Spaces
- Get Subform Control Name
- The Opposite of DSum()
- Concatenate Records
- Get Network Domain Name
- Get Computer Name
- Get BE Info
- Execute Action Queries
- Extract Email Address