Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / January 2007

Tip: Looking for answers? Try searching our database.

Cryptic compile error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
requeth@gmail.com - 24 Jan 2007 15:48 GMT
I'm getting the error message:

"Compile error: Function call on left-hand side of assignment must
return Variant or Object"

I am attaching my module below, it is selecting the MsgBox line when I
choose ok after the error. I do not see anything wrong, but I have no
idea what the help file is talking about. Does anyone see what the
issue is?

Option Compare Database

Public Declare Function apiLogOut Lib "advapi32.dll" Alias
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function auditlog() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
Dim v_user As String
Dim Authorized As Boolean
Dim Authload
Dim strMsg
   strUserName = String$(254, 0)
   lngLen = 255
   lngX = apiLogOut(strUserName, lngLen)
   If lngX <> 0 Then
       auditlog = Left$(strUserName, lngLen - 1)
   Else
       auditlog = "No ID"
   End If
 v_user = auditlog
Authload = "SELECT COUNT(*) FROM PTEAM WHERE FXID='" & v_user & "'"
DoCmd.SetWarnings False
DoCmd.RunSQL Authload
DoCmd.SetWarnings True
If Authload = 1 Then
   Authorized = Yes
Else
   Authorized = No

 sqlInsertStatement = "Insert into
UserLog([UserName],[LoginDate],[LoginTime],[StatusType],[Authorized])
Values('" & v_user & "','" & Format(Date, "mm\/dd\/yyyy") & "','" &
Time & "','Logout','" & Authorized & "')"
 DoCmd.SetWarnings False
 DoCmd.RunSQL sqlInsertStatement
 DoCmd.SetWarnings True
If Authorized = No Then
strMsg = "Access is not permitted. Please speak with the process team
leader for further guidance."
   MsgBox(strMsg, vbOKOnly, "Access Error") = _
vbOK
   Private Sub AppExit_Click()
   Application.Quit acPrompt
Else
   DoCmd.OpenForm "MainMenu"
           
End Sub
Stefan Hoffmann - 24 Jan 2007 16:01 GMT
hi,

> Option Compare Database
Add an Option Explicit in all of your modules here.

> Function auditlog() As String
In your code there is no End Function.

> If Authload = 1 Then
>     Authorized = Yes
> Else
>     Authorized = No
Yes and No are undeclared variables.

mfG
--> stefan <--
Marshall Barton - 24 Jan 2007 16:09 GMT
>I'm getting the error message:
>
[quoted text clipped - 5 lines]
>idea what the help file is talking about. Does anyone see what the
>issue is?
[snip]
>    MsgBox(strMsg, vbOKOnly, "Access Error") = _
>              vbOK

As the error message indicates, assigning a value to the
result of a function call is a pretty tricky thing to do.

Perhaps you meant it to be a comparison in an If statement?

Signature

Marsh
MVP [MS Access]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.