G
Guest
Hi,
I have an Access 2000 db with a user table showing the various user levels
(such as NormalUser, SeniorUser, Security, Admin, and Designer).
At startup I use the Win32 API to get the NT Username. Then I want to
compare the NT Username with the records in the table to find out the user
access level - then I can show the correct menu according to the users
permissions.
Here is the SQL Query that I need to run in VBA:
"SELECT userLevel from Users where NTUserName = '" & sUser & "'"
and the database is the CurrentDB (called "Project Eagle.mdb")
How do I do that please?
(Normally in MS Excel VBA or VB 6 I would use ADO, and have limited
knowledge of Access or DAO).
I tried to use the code in the Help (Northwind) for this, but I got an
'Unrecognized Database format' error.
Here is the code I tried to use:
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
Set dbsEagle = wrkJet.OpenDatabase("Project Eagle.mdb")
' Set rstTemp = CurrentDb.OpenRecordset("SELECT userLevel from Users
where ' NTUserName = '" & sUser & "'", dbOpenDynaset, dbReadOnly)
Set rstTemp = dbsEagle.OpenRecordset( _
"SELECT userLevel Users where NTUserName = '" & sUser & "'",
dbOpenDynaset, dbReadOnly)
intUserLevel = rstTemp!userLevel
getUserLevel = intUserLevel
<<< end code <<<
Unfortunately it fails on the Set dbsEagle = wrkJet.OpenDatabase line with
'unrecognized database format' error.
Is there a better or simpler way to do what I want in VBA just to get the
user level from the table Users?
thanks for any help
Philip
I have an Access 2000 db with a user table showing the various user levels
(such as NormalUser, SeniorUser, Security, Admin, and Designer).
At startup I use the Win32 API to get the NT Username. Then I want to
compare the NT Username with the records in the table to find out the user
access level - then I can show the correct menu according to the users
permissions.
Here is the SQL Query that I need to run in VBA:
"SELECT userLevel from Users where NTUserName = '" & sUser & "'"
and the database is the CurrentDB (called "Project Eagle.mdb")
How do I do that please?
(Normally in MS Excel VBA or VB 6 I would use ADO, and have limited
knowledge of Access or DAO).
I tried to use the code in the Help (Northwind) for this, but I got an
'Unrecognized Database format' error.
Here is the code I tried to use:
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
Set dbsEagle = wrkJet.OpenDatabase("Project Eagle.mdb")
' Set rstTemp = CurrentDb.OpenRecordset("SELECT userLevel from Users
where ' NTUserName = '" & sUser & "'", dbOpenDynaset, dbReadOnly)
Set rstTemp = dbsEagle.OpenRecordset( _
"SELECT userLevel Users where NTUserName = '" & sUser & "'",
dbOpenDynaset, dbReadOnly)
intUserLevel = rstTemp!userLevel
getUserLevel = intUserLevel
<<< end code <<<
Unfortunately it fails on the Set dbsEagle = wrkJet.OpenDatabase line with
'unrecognized database format' error.
Is there a better or simpler way to do what I want in VBA just to get the
user level from the table Users?
thanks for any help
Philip