I got a blank comboboxDoes that mean you got a compile error, a run time error, or the wrong result?
What is Credentials.AccessLvlID referring to? You can't just reference a table/query this way. Do you have an object named "Credentials" that has methods and properties?
Credentials is a module that deals with the AccessLvlID of the users who log in and is the basis of what they can and cannot see in the database like forms, fields, labels etc and now reports. In my database when you want to restrict or allow access to areas or items the code will start with Credentials.UserName or Credentials.AccessLvlID
For reference this is my Credentials module
Code:
Option Compare Database
Option Explicit
Public UserName As String
Public UserId As Integer
Public AccessLvlID As Integer
Public Function GetCurrentUser() As Integer
GetCurrentUser = UserId
End Function
Public Function GetCurrentUserFacility() As String
GetCurrentUserFacility = DLookup("FacilityNumber", "tbl_users", "ID = " & Credentials.UserId)
End Function
Public Function GetCurrentUserFacility2() As String
On Error GoTo NoFacility
GetCurrentUserFacility2 = DLookup("FacilityNumber2", "tbl_users", "ID = " & Credentials.UserId)
Exit Function
NoFacility:
GetCurrentUserFacility2 = ""
End Function
As an example on my main form this code exists and uses Credentials to perform various functions when the form opens
Code:
Private Sub Form_Open(Cancel As Integer)
Dim dbs As DAO.Database
Dim FEVersion As Variant
Set dbs = CurrentDb
If Credentials.AccessLvlID = 0 Then
DoCmd.OpenForm "frm_loginform"
Cancel = 1
End If
If Credentials.AccessLvlID = 1 Then
If Weekday(Now) = vbMonday Then
WaitVis
WaitLab
SendEMail
End If
End If
If Credentials.UserId = 2 Then
dbs.Execute "AppendNewPONumbers", dbFailOnError
dbs.Execute "AppendNewPoNumbers_WNK", dbFailOnError
End If
FEVersion = DLookup("fe_version_number", "tbl-fe_version")
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tbl_users SET Version = '" & FEVersion & "' WHERE ID = " & Credentials.UserId
If Credentials.AccessLvlID = 6 Then
MsgBox "Your Account Has Been Deactivated. Please Contact the Administrator."
DoCmd.Quit
End If
End Sub