military donut
asked on
Db startup dlookup not working
Hello I have the below code and on the part
Check=
I get an error
The expression you entered as a query parameter produced this error 'username' (this shows the username if the person on the computer)
Again I have this running on startup as an autoexec
I have the function : CheckName running first thing
Check=
I get an error
The expression you entered as a query parameter produced this error 'username' (this shows the username if the person on the computer)
Again I have this running on startup as an autoexec
I have the function : CheckName running first thing
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
Public Function CheckName()
Call fOSUserName
Dim Check As String
Dim User As String
User = fOSUserName
Check = DLookup("UserName", "tblUser", User)
Debug.Print Check
If fOSUserName = Check Then
Call DisClaimStartup
Else
MsgBox "You must be a valid User to use SLED"
DoCmd.Quit
Cancel = True
Exit Function
End If
End Function
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Both of you are absolutely right. I wasn't thinking clearly on the null .
Thanks to both of you. Great help!
Thanks to both of you. Great help!
oops
Check = DLookup("UserName", "tblUser", "[UserName] = " & Chr(34) & User & Chr(34) )
Check = DLookup("UserName", "tblUser", "[UserName] = " & Chr(34) & User & Chr(34) )
ASKER
Edited this response
?