Craig,
Just because you have a "startup form" doesn't mean that you can't create
another form that opens (hidden) *before* your startup form opens.
So......
create a new standard module and paste in the following code:
'I got this code from
' rogersaccesslibrary.com
' a file: AuditTrail.mdb (intermediate)
'
http://www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=399
'---------------------------
Option Compare Database
Option Explicit
Private Declare Function GetComputerNameA Lib "kernel32" (ByVal lpBuffer As
String, nSize As Long) As Long
Private Declare Function GetUserName Lib "ADVAPI32.dll" Alias "GetUserNameA"
(ByVal lpBuffer As String, nSize As Long) As Long
Public Function GetComputerName() As String
On Error GoTo Err_GetComputerName
Dim Username As String * 255
Call GetComputerNameA(Username, 255)
GetComputerName = Left$(Username, InStr(Username, Chr$(0)) - 1)
Exit_GetComputerName:
Exit Function
Err_GetComputerName:
MsgBox Err.Description
Resume Exit_GetComputerName
End Function
Public Function GetCurrentUserName() As String
On Error GoTo Err_GetCurrentUserName
Dim lpBuff As String * 25
Dim ret As Long, Username As String
ret = GetUserName(lpBuff, 25)
Username = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
GetCurrentUserName = Username & ""
Exit_GetCurrentUserName:
Exit Function
Err_GetCurrentUserName:
MsgBox Err.Description
Resume Exit_GetCurrentUserName
End Function
'---------------------------
Save the module - name it "UserComputer"
Now create a new form, set the visible property to NO, add a text box (that
will hold the user ID). Name the text box "UserID". Add this code:
'---------------------------
Private Sub Form_Load()
Me.UserID = GetCurrentUserName()
DoCmd.OpenForm "YourStartUpFormName"
End Sub
'---------------------------
Change "YourStartUpFormName" in the code above to the name of your startup
form.
So, the hidden form opens first, gets the user ID, then opens your startup
form. You can get the UserID anytime from the hidden form by referencing the
text box on the hidden form.
There is also an advanced Audit trail example at:
http://www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=398
HTH
Thanks for everyone's help in this matter. Unfortunately, I already have a
startup form that is visible to the users. What I am told I can do, but
[quoted text clipped - 24 lines]