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"
mainfrm.toobar1.enable=true
case Str_T="Operator"
mainfrm.toolbar1.enable=False
End SELECT

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

Recommended Answers

All 8 Replies

Why not use a dynamic parametrized dynamic SQL to handle the requirement.

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"
    mainfrm.toobar1.enable=true
case "Operator"
    mainfrm.toolbar1.enable=False
End SELECT

dear das please explain SQL how to use?

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'")

Hi zebnoon,

This thread already solved??

commented: why are you iso interested in getting the thread solved ? -3
commented: counter +13

not yet .sir i will come soon on this issue.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.