Hell all I have problem to login as administrator and as Operator with less permissions.
following code .i create and open recoedset "Type_rs"

dim Str_T as String
SELECT Case Type_rs.Field("User Type")=Str_t
Case str_t="Administrator"
case Str_T="Operator"

I thing Type_rs.Field("User Type")=Str_t is not working properlly please .Help me.

What the function of Str_T?

Also your select case is wrong. Just fill Type_rs with user type information from db (With Type_rs.Open ...) .

SELECT Case Type_rs.Field("User Type")
Case "Administrator"
case "Operator"

dear JX code is not workin please check my code

Dim db As DAO.Database
Dim Type_rs As DAO.Recordset

Set db = OpenDatabase("E:\Projects\TS\database\MyDb.mdb")
Set Type_rs = db.OpenRecordset("SELECT * FROM User_Tab")

Select Case Type_rs.Fields("Type")
Case "Administrator"
mainfrm.MnuOption.Enabled = True
mainfrm.Toolbar1.Enabled = True
Case "Operator"
mainfrm.MnuReg.Enabled = False
End Select

Your code is running good but you need to specify the select statement query.
You cannot select entire data and compare it on select-case, select-case will get wrong input. So you need to specify data from db.
I don't know what the fields on your User_Tab Table but i try to give an example.
With this query, select-case will get right input :

'Specify your query to get right data
Set Type_rs = db.OpenRecordset("SELECT * FROM User_Tab Where UserName = 'Admin' And Password = 'admin'")

You need to get a username, either display a dialog box and prompt for the user to type it in or retrieve the windows username.

Retrieve the record from the database as follows:
Set Type_rs = db.OpenRecordset("SELECT * FROM User_Tab Where UserName = '" & stUserName & "'; ")

Now do your select statement as above

This article has been dead for over six months. Start a new discussion instead.