Unanswered: Storing the result of a query in a global variable
Hi, i need help (figures why i'm here right..). I'm trying to store the result of a query in a global variable, but i don't know how to do this, so could you look at this code and point me in the right direction ?
Option Compare Database
Dim gstrUserLevel As String
'gstrUserLevel stores the user's level of access
Public Sub Login()
'This procedure logins the user, checks the user level and takes them to the appropriate forms
Dim pstrUserID As String
Dim pstrUserPass As String
Dim pintAccess As Integer
'pstrUserID = Forms![frmSwitchboard]![txtUserID]
pstrUserID = "User"
'pstrUserPass = Forms![frmSwitchboard]![txtPassword]
pstrUserPass = "user"
'create a connection object
Dim cnn As ADODB.Connection
Dim cmd As New ADODB.Command
Dim plngRecordsAffected As Long
Set cnn = CurrentProject.Connection
cmd.ActiveConnection = cnn
cmd.CommandText = "qryLoginUser"
cmd.Execute plngRecordsAffected, Array(pstrUserID, pstrUserPass)
the query results in 'Admin' but i want to store this result in a variable gstrUserLevel.
If someone can help me before April 30th, i'd be really happy
Thanx . I'm sorry about that, didn't think it was necessary. Admin is one of four access levels stored for a user: Admin,Tech,Accts,Ags. The goal is to store the access level from the query, which has the parametes userid and userpass then only allow them to access specific forms based on their access level.
the code which follows goes kind of like this:
If gstrUserLevel = "Admin" Then
MsgBox "Logged in As " & gstrUserLevel
so on and so forth