P
Paul Ponzelli
I'm trying to get a form to open to a record corresponding to the operating
system User Name.
I'm trying to use the following code:
Private Sub Form_Open(Cancel As Integer)
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[EmployeeID] = '" & DLookup("EmployeeID", "Employee",
[UserName] = fOSUserName()) & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
I know the problem is not the the function fOSUserName(), because I've
watched its value as I step through the code, and it correctly returns the
user name. The problem is that the DLookup() function is not obtaining the
corresponding value of the EmployeeID. The form just opens to the first
record in the underlying recordset, not to the record that corresponds to
the value in the UserName field.
So I'm thinking the problem is with the syntax in the DLookup statement.
Can anyone tell me what I can do to get the DLookup() function to return the
correct EmployeeID?
Thanks in advance,
Paul
system User Name.
I'm trying to use the following code:
Private Sub Form_Open(Cancel As Integer)
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[EmployeeID] = '" & DLookup("EmployeeID", "Employee",
[UserName] = fOSUserName()) & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
I know the problem is not the the function fOSUserName(), because I've
watched its value as I step through the code, and it correctly returns the
user name. The problem is that the DLookup() function is not obtaining the
corresponding value of the EmployeeID. The form just opens to the first
record in the underlying recordset, not to the record that corresponds to
the value in the UserName field.
So I'm thinking the problem is with the syntax in the DLookup statement.
Can anyone tell me what I can do to get the DLookup() function to return the
correct EmployeeID?
Thanks in advance,
Paul