John W. Vinson replied to mboren via AccessMonster.com
29-Jan-10 12:55 PM

My suggested table would automatically fill in the date AND let them enter
their diary. You can display it on a Continuous Form so you can see past
entries easily.
If you insist. Put a Command Button cmdDiary on the form with a Caption of
This will display Diary with the y underlined, and typing Alt-Y on the
keyboard will click the button. In its code put
Private Sub cmdDiary_Click()
Dim Username as String
Username = fOSUserName()
Me!txtMemofield.SetFocus
Me!txtMemofield = Me!txtMemofield & vbCrLf & Date & " " & Username
Me!txtMemofield.SelStart = Len(Me!txtMemofield)
End Sub
'******************** Code Start **************************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If ( lngX > 0 ) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
'******************** Code End **************************
The fOSUserName code is from http://mvps.org/access/api/api0008.htm (and there
are tons more useful code on that site).
--
John W. Vinson [MVP]