Randomblink
The Irreverent Reverend
- Local time
- Today, 17:03
- Joined
- Jul 23, 2001
- Messages
- 279
Ack!
I have this freaking database ready to run...
But I have hit a glitch.
Here is the FUNCTION I use to grab the Users NT Username:
__________________________________________________
Option Compare Database
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public Function GetNTUser() As String
'Returns the network login name
Dim strUserName As String
'Create a buffer
strUserName = String(100, Chr$(0))
'Get user name
GetUserName strUserName, 100
'Strip the rest of the buffer
strUserName = Left$(strUserName, InStr(strUserName, Chr$(0)) - 1)
GetNTUser = strUserName
End Function
__________________________________________________
Here is the FUNCTION I am having PROBLEMS with:
__________________________________________________
Public Function CopySwap()
Dim TrgtLoc As String
On Error GoTo Err_CopySwap
' Create a target that points to where the new version should go.
TrgtLoc = "C:\WINNT\Profiles\" & GetNTUser & "\Desktop\ProjectStatus.mdb"
' Start up the COPY FUNCTION.
Set fs = CreateObject("Scripting.FileSystemObject")
' Get the original Template and copy it to where new versions go. (True means to overwrite if a copy exists.)
fs.CopyFile "\\PWC\Engineering\wpdata\reports\Databases\Front_End_Databases\Tmpl_ProjectStatus.mdb", TrgtLoc, True
' Start up the OPEN DATABASE FUNCTION.
Set appAccess = CreateObject("Access.Application")
' Open the new database that was just copied from the Template.
appAccess.OpenCurrentDatabase TrgtLoc, False
' Close the old version of the database.
DoCmd.Quit acQuitSaveNone
Exit_CopySwap:
Exit Function
Err_CopySwap:
MsgBox Err.Description
Resume Exit_CopySwap
End Function
__________________________________________________
What I am wanting to do is:
I have other functions that check the version number of the Master template on the server. IF the Master Template has a different version number, then CopySwap runs...
GetNTUser returns bokeefe if I am signed on...
So the CopyFile copies the front end right where I want it...
C:\WINNT\Profiles\bokeefe\Desktop
No problems so far...
My problem comes when an Engineer in my group tries to use this function...
Her NT Sign on is (for example) SJohnson
BUT her actual Desktop location is:
C:\WINNT\Profiles\SSmith\Desktop
Because she recently divorced and switched to her old name...
ARGH!
Is there someway to point to the Desktop NO MATTER what their usernames are?
Help me!
I have this freaking database ready to run...
But I have hit a glitch.
Here is the FUNCTION I use to grab the Users NT Username:
__________________________________________________
Option Compare Database
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public Function GetNTUser() As String
'Returns the network login name
Dim strUserName As String
'Create a buffer
strUserName = String(100, Chr$(0))
'Get user name
GetUserName strUserName, 100
'Strip the rest of the buffer
strUserName = Left$(strUserName, InStr(strUserName, Chr$(0)) - 1)
GetNTUser = strUserName
End Function
__________________________________________________
Here is the FUNCTION I am having PROBLEMS with:
__________________________________________________
Public Function CopySwap()
Dim TrgtLoc As String
On Error GoTo Err_CopySwap
' Create a target that points to where the new version should go.
TrgtLoc = "C:\WINNT\Profiles\" & GetNTUser & "\Desktop\ProjectStatus.mdb"
' Start up the COPY FUNCTION.
Set fs = CreateObject("Scripting.FileSystemObject")
' Get the original Template and copy it to where new versions go. (True means to overwrite if a copy exists.)
fs.CopyFile "\\PWC\Engineering\wpdata\reports\Databases\Front_End_Databases\Tmpl_ProjectStatus.mdb", TrgtLoc, True
' Start up the OPEN DATABASE FUNCTION.
Set appAccess = CreateObject("Access.Application")
' Open the new database that was just copied from the Template.
appAccess.OpenCurrentDatabase TrgtLoc, False
' Close the old version of the database.
DoCmd.Quit acQuitSaveNone
Exit_CopySwap:
Exit Function
Err_CopySwap:
MsgBox Err.Description
Resume Exit_CopySwap
End Function
__________________________________________________
What I am wanting to do is:
I have other functions that check the version number of the Master template on the server. IF the Master Template has a different version number, then CopySwap runs...
GetNTUser returns bokeefe if I am signed on...
So the CopyFile copies the front end right where I want it...
C:\WINNT\Profiles\bokeefe\Desktop
No problems so far...
My problem comes when an Engineer in my group tries to use this function...
Her NT Sign on is (for example) SJohnson
BUT her actual Desktop location is:
C:\WINNT\Profiles\SSmith\Desktop
Because she recently divorced and switched to her old name...
ARGH!
Is there someway to point to the Desktop NO MATTER what their usernames are?
Help me!