Using Access 2010 (64bit) on Windows 7 64-bit
I have a form with two fields in it.
The first is WeekEndDate.
For the default value, I put [highlight #3465A4]=Date()+(7-Weekday(Date()))[/highlight] with the expectation of opening the form and seeing Today's Weekending Date. Instead, I get the date that was in the field last time the form was open.
What am I missing here?
The second is Name.
The Control Source for this field is Name from tblPeople. It is a dropdown list where you can pick the name of the person. It is bound to column 1, which is your Windows Login field. I want it to default to the person using the computer. I have a module
I set the Default Value to the form field to =fOSUserName()
Everytime I open the form, it returns the name of the person selected last time the form was opened. What am I missing here?
I have a form with two fields in it.
The first is WeekEndDate.
For the default value, I put [highlight #3465A4]=Date()+(7-Weekday(Date()))[/highlight] with the expectation of opening the form and seeing Today's Weekending Date. Instead, I get the date that was in the field last time the form was open.
What am I missing here?
The second is Name.
The Control Source for this field is Name from tblPeople. It is a dropdown list where you can pick the name of the person. It is bound to column 1, which is your Windows Login field. I want it to default to the person using the computer. I have a module
Code:
Private Declare PtrSafe Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
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 **************************
I set the Default Value to the form field to =fOSUserName()
Everytime I open the form, it returns the name of the person selected last time the form was opened. What am I missing here?