Results 1 to 5 of 5
  1. #1
    vickan240sx is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2012
    Posts
    34

    Security Levels - GetUser()

    Hi,

    I'm getting an error when try to open up my login form I've taken this code from a sample Getuser() database, but I can't seem to figure out what I'm missing.

    Compile Error:
    User-defined type not defined

    Code:
    Option Compare Database
    Function isAdmin() As Boolean
    Dim LID As Variant
    LID = GetUser()
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    strSQL = "Select * from dbo_AdminTable where LoginID = '" & LID & "'"
    rs.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockReadOnly
    If rs.EOF And rs.BOF Then
        isAdmin = False
    Else
        isAdmin = True
    End If
    rs.Close
    Set rs = Nothing
    End Function
    Function retFullName() As String
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    strSQL = "Select * from dbo_AdminTable where LoginID = '" & GetUser() & "'"
    rs.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockReadOnly
    If rs.EOF And rs.BOF Then
        retFullName = "Name Not Found"
    Else
        retFullName = rs!FirstName & " " & rs!LastName
    End If
    rs.Close
    Set rs = Nothing
    End Function
    Function retSecDescription() As String
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    strSQL = "SELECT dbo_LookupSecurity.SecurityDescription, dbo_AdminTable.LoginID" _
    & " FROM dbo_AdminTable INNER JOIN dbo_LookupSecurity ON dbo_AdminTable.SecurityLevel = dbo_LookupSecurity.SecurityLevel" _
    & " WHERE (((dbo_AdminTable.LoginID)= '" & GetUser() & "'))"
    rs.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockReadOnly
    If rs.EOF And rs.BOF Then
        retSecDescription = "Unknown"
    Else
        retSecDescription = rs!SecurityDescription
    End If
    rs.Close
    Set rs = Nothing
    End Function
    Function retSecNum() As Integer
    Dim strSQL As String
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    strSQL = "Select * from dbo_AdminTable where LoginID = '" & GetUser() & "'"
    rs.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockReadOnly
    If rs.EOF And rs.BOF Then
        retSecNum = 1
        Else
        retSecNum = rs!SecurityLevel
    End If
    rs.Close
    Set rs = Nothing
    End Function
    The
    Code:
     rs As ADODB.Recordset
    is highlighted.



    My user name is able to fill in correctly, however the "Your Name", "Security Level", and "Security Description" is getting an error.

    Your help is greatly appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Do you have VBA reference set for:

    Microsoft ActiveX Data Objects 2.x Library
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    vickan240sx is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2012
    Posts
    34
    Quote Originally Posted by June7 View Post
    Do you have VBA reference set for:

    Microsoft ActiveX Data Objects 2.x Library
    What's that?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    From the VBA editor menu>Tools>References>scroll down and select. http://msdn.microsoft.com/en-us/libr...ffice.12).aspx
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    vickan240sx is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2012
    Posts
    34
    you guys are awesome. Thank you so much.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. GetUser method
    By pkstormy in forum Code Repository
    Replies: 7
    Last Post: 11-22-2012, 06:00 PM
  2. Form for users to set security levels
    By smahdih in forum Forms
    Replies: 2
    Last Post: 11-14-2011, 06:22 PM
  3. GetUser()
    By hitesh_asrani_j in forum Forms
    Replies: 4
    Last Post: 10-17-2011, 03:47 AM
  4. How to sum at levels in a query
    By Sck in forum Queries
    Replies: 2
    Last Post: 12-08-2010, 09:39 AM
  5. =GetUser() Function
    By Desstro in forum Programming
    Replies: 9
    Last Post: 11-02-2010, 09:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums