I got a code from another dbs that sort of does what I need. I can't get it to work though. Here it is:
*************START CODE********************
Option Compare Database
'windows-defined type
Private Type SYSTEM_INFO
dwOemID As Long
End Type
Private Declare Sub GetSystemInfo Lib "kernel32" (lpSystemInfo As SYSTEM_INFO)
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (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
Private Type ComputerUserInfo
username As String
ComputerName As String
End Type
Private Sub GetUserInfo(CUI As ComputerUserInfo)
Dim r&, ret$
'get the user's name
ret$ = Space$(256)
r& = GetUserName(ret$, Len(ret$))
CUI.username = StripNull$(ret$)
'get the computers's name
ret$ = Space$(256)
r& = GetComputerName(ret$, Len(ret$))
CUI.ComputerName = StripNull$(ret$)
End Sub
Private Sub DisplayResults(CUI As ComputerUserInfo)
'fill in the labels
' Label1 = "User Name :"
' Label1 = "Computer Name :"
'show the info
'Computer User Info and Windows Registry Info
Text1 = CUI.username
Text2 = CUI.ComputerName
End Sub
Private Function StripNull$(item$)
On Local Error Resume Next
StripNull$ = Left$(item$, InStr(item$, Chr$(0)) - 1)
End Function
Private Sub Command43_Click()
On Error GoTo ITF_Macro_Err
Dim CUI As ComputerUserInfo
'Dim db As DAO.Database
'Dim rst As DAO.Recordset
Dim stLastUp As String
'Dim stSSAN as String
'stSSAN = Me.SSAN.Value
'Set db = CurrentDb
'Set rst = db.OpenRecordset("SELECT * FROM [Query1] WHERE [SSAN] = stSSAN;")
'rst.MoveFirst
With Me.Text67
.Value = CUI.username
End With
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenQuery "Exit Refresh", acViewNormal, acEdit
DoCmd.Close acForm, "Individual Tracking Form"
DoCmd.OpenForm "Main Menu", acNormal
ITF_Macro_Exit:
Exit Sub
ITF_Macro_Err:
DoCmd.Close acForm, "Individual Tracking Form"
Resume ITF_Macro_Exit
End Sub
*******************END CODE***********************
I have a textbox on the Individual Tracking Form that I need to automatically update once data has been saved to the record. I want it to reflect the name of the user who made the last update. I know I ask a lot of questions but I have to learn somewhere if I can find the answer. Thanks in advance.
*************START CODE********************
Option Compare Database
'windows-defined type
Private Type SYSTEM_INFO
dwOemID As Long
End Type
Private Declare Sub GetSystemInfo Lib "kernel32" (lpSystemInfo As SYSTEM_INFO)
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (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
Private Type ComputerUserInfo
username As String
ComputerName As String
End Type
Private Sub GetUserInfo(CUI As ComputerUserInfo)
Dim r&, ret$
'get the user's name
ret$ = Space$(256)
r& = GetUserName(ret$, Len(ret$))
CUI.username = StripNull$(ret$)
'get the computers's name
ret$ = Space$(256)
r& = GetComputerName(ret$, Len(ret$))
CUI.ComputerName = StripNull$(ret$)
End Sub
Private Sub DisplayResults(CUI As ComputerUserInfo)
'fill in the labels
' Label1 = "User Name :"
' Label1 = "Computer Name :"
'show the info
'Computer User Info and Windows Registry Info
Text1 = CUI.username
Text2 = CUI.ComputerName
End Sub
Private Function StripNull$(item$)
On Local Error Resume Next
StripNull$ = Left$(item$, InStr(item$, Chr$(0)) - 1)
End Function
Private Sub Command43_Click()
On Error GoTo ITF_Macro_Err
Dim CUI As ComputerUserInfo
'Dim db As DAO.Database
'Dim rst As DAO.Recordset
Dim stLastUp As String
'Dim stSSAN as String
'stSSAN = Me.SSAN.Value
'Set db = CurrentDb
'Set rst = db.OpenRecordset("SELECT * FROM [Query1] WHERE [SSAN] = stSSAN;")
'rst.MoveFirst
With Me.Text67
.Value = CUI.username
End With
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenQuery "Exit Refresh", acViewNormal, acEdit
DoCmd.Close acForm, "Individual Tracking Form"
DoCmd.OpenForm "Main Menu", acNormal
ITF_Macro_Exit:
Exit Sub
ITF_Macro_Err:
DoCmd.Close acForm, "Individual Tracking Form"
Resume ITF_Macro_Exit
End Sub
*******************END CODE***********************
I have a textbox on the Individual Tracking Form that I need to automatically update once data has been saved to the record. I want it to reflect the name of the user who made the last update. I know I ask a lot of questions but I have to learn somewhere if I can find the answer. Thanks in advance.