Difference between revisions of "Microsoft Access modWsh"

From database24
Jump to navigation Jump to search
(Created page with '=== getUserName === <syntaxhighlight lang="vb"> Function getUserName() As String Dim strResult As String Dim wshNet As WshNetwork Set wshNet = New WshNetwor...')
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 +
[[Category:Microsoft Access]]
 +
[[Category:VBA]]
 
=== getUserName ===
 
=== getUserName ===
 
<syntaxhighlight lang="vb">
 
<syntaxhighlight lang="vb">
Line 53: Line 55:
 
      
 
      
 
     getUserTempTable = strResult
 
     getUserTempTable = strResult
 +
End Function
 +
</syntaxhighlight>
 +
 +
=== getUserTempQuery ===
 +
<syntaxhighlight lang="vb">
 +
Public Function getUserTempQuery(strSource As String) As String
 +
    Dim strResult As String
 +
 +
    Const strTablePrefix = "_qry"
 +
 +
    strResult = strTablePrefix & Mid(strSource, 4) & getUserSuffix
 +
 +
    getUserTempQuery = strResult
 
End Function
 
End Function
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 13:47, 1 September 2010

getUserName

Function getUserName() As String
    Dim strResult As String
    
    Dim wshNet As WshNetwork
    
    Set wshNet = New WshNetwork
    strResult = wshNet.UserName
    
    getUserName = strResult
End Function

getComputerName

Function getComputerName() As String
    Dim strResult As String
    
    Dim wshNet As WshNetwork
    
    Set wshNet = New WshNetwork
    strResult = wshNet.ComputerName
    
    getComputerName = strResult
End Function

getUserSuffix

Public Function getUserSuffix() As String
    Dim strResult As String
    
    strResult = getUserName
    strResult = Replace(strResult, ".", "")
    strResult = Replace(strResult, ",", "")
    strResult = Replace(strResult, "-", "")
    strResult = Replace(strResult, " ", "")
    strResult = "_" & strResult
    
    getUserSuffix = strResult
End Function

getUserTempTable

Public Function getUserTempTable(strSource As String) As String
    Dim strResult As String
    
    Const strTablePrefix = "_tbl"
    
    strResult = strTablePrefix & Mid(strSource, 4) & getUserSuffix
    
    getUserTempTable = strResult
End Function

getUserTempQuery

Public Function getUserTempQuery(strSource As String) As String
    Dim strResult As String
 
    Const strTablePrefix = "_qry"
 
    strResult = strTablePrefix & Mid(strSource, 4) & getUserSuffix
 
    getUserTempQuery = strResult
End Function