Make a temporary table with a unique name

  • Thread starter Thread starter Robert
  • Start date Start date
R

Robert

How could you give a table you were making at run time a unique name for
each user? By that I mean what could you concatenate into a table name so
it would be different from another user's table if they were both running
the program at the same time? The time itself would work as long as both
users didn't create the table at the exact same second. But it could
happen that both created a table at the exact same second.

Would this even be necessary if the 2 user's had their own mde's (but the
same back end)?

Robert
 
Hi Robert,
very often, you would want the user to create the temp table in the same
folder as their copy of the front end. You do this if the temp table holds
data which does not need to be seen by other users.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
I need a method when there is only one copy of the front end and multiple
users. The user's login or something.
 
Robert,
There is a function called GetNetworkUserName from Allen Browne's website.

Public Function GetNetworkUserName() As String
On Error GoTo Err_Handler
'Purpose: Returns the network login name
'Return: The name, or "{Unknown}" on error.
'Note: Safer than testing Environ().
Dim lngLen As Long
Dim lngX As Long
Dim strUserName As String

strUserName = String$(254, 0&)
lngLen = 255&
lngX = apiGetUserName(strUserName, lngLen)
If (lngX > 0&) Then
strUserName = Left$(strUserName, lngLen - 1&)
End If

If strUserName <> vbNullString Then
GetNetworkUserName = strUserName
Else
GetNetworkUserName = "{unknown}"
End If

Exit_Handler:
Exit Function

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".fOSUserName")
Resume Exit_Handler
End Function


Multiple users all using the same copy of the front end is a corruption
disaster waiting to happen. Sooner or later it will happen to this front
end. I strongly advise you to give each user their own copy of the front
end.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
You forgot to include the declaration for apiGetUserName:

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

The code won't work without that declaration.
 
Thanks Doug.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
Back
Top