Error Compiling a function
Posted on 2002-07-24
I copied a startup() function into the database that I'm Working on right now. This function gets the user's NT userID and other misc. info and then uses it to do some security.
When I imported the function and tried to test it I got the following error:
"There was an error compiling a function"
The Visual Basic module contains a syntax error - check the code and then recompile it"
The function runs fine on the database that I imported it from. Below is the VB for the function and I put the line that the compile bites on in quotes.
Option Compare Database
Declare Function API_GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Declare Function GetComputerName& Lib "KERNEL32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long)
Global gbUpdateUser As Boolean
Global gsSQL As String
Dim msUserID As String
Dim msSQL As String
Dim mRS As Recordset
"Dim mDB As Database"
Public Function Startup() As Boolean
gbUpdateUser = False
msUserID = GetUserName()
Set mDB = CurrentDb
msSQL = "SELECT * FROM tblUsers WHERE tblUsers.NTID= '" & msUserID & " ';"
Set mRS = mDB.OpenRecordset(msSQL, dbOpenSnapshot)
If Not .EOF Then
If .RecordCount > 0 _
And !admin = True Then
gbUpdateUser = True
Set mRS = Nothing
Set mDB = Nothing
MsgBox "Welcome to the Problem Report Database", vbInformation + vbOKOnly, "Welcome"
Does anyone have any idea why this would happen on the new database and not on the one I copied it from. I'm using Access2000 and Windows2000. Thanks very much.
P.S I didn't paste in the entire code so if you wonder why something might be missing.....