Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vb Access Permissions 1

Status
Not open for further replies.

timotai

Technical User
Apr 13, 2002
119
GB
I have created my database so that it users the NT id which is checked against a table to authorise access into the database. I also have code to lock out all the toolbars and the database window from users. Now what I need to do is tie it all together and create permissions so that Admin users have full access whereas normal users are restricted (i.e. the no tollbars, etc. code I spoke of earlier)

I have created a table called Team members which looks like below:

Employee Number Firstname Surname Level Access
3333333 User One User
4343434 User Two User
4444444 User Three User
5555555 User Four Administrator

I use Environ$("username") to grab the NT ID

What I need to do is create a vb script that will do:

1)
lookup result of Environ$("username") in team members table!

= 5555555 and script has found the user

is user access Admin?

Yes

Then GoTo End

2)
lookup result of Environ$("username") in team members table!

= 3333333 and script has found the user

is user access Admin?

No

Then GoTo Lock toolbars script

I hope this gives you a good idea of what I am trying to do.

All help is very very much appreciated

Many Thanks

Timotai
[thumbsup2]
(Knowledge is someone else's inspiration)
 
Why don't you use user and groups in menu Tools => Security.
So you add groups with permissions, and add NT users to this groups.

This will be more secure than using the "username" variant.

Then during database initializaton, you only have to hide toolbars that give access to information not authorised by current user permissions.
You'll only have to check groups of current user.
And even if you don't hide a toolbar, a user will not have access to a prohibited table or other.
 
Our guidlines in the office for using the PC's (i.e. if you leave your desk lock your workstation, donot tell anyone else your password, etc.) should provide enough security for the database when using this function. I am also going to switch off the F11 and shift overrides. I don't what the users to have to try to remember another password and so this method is perfect for so many other reason for this specific database. But due to me using this method I can't use security permissions.

Many Thanks for the Tip though. As I said any reply's are considered and appreciated.
 
Are tou searching for this ?

Dim LevelAccess As String

LevelAccess = Nz(DFirst("LevelAccess", "TableTeamMembers", "UserNameField='" + Environ$("username")) + "'", "")

If LevelAccess = "Administrator" Then Exit Sub
'Lock toolbars here
...
 
I've changed it slightly but I keep getting an error. It looks like exactly what I want. Here is what it is looking like

Dim LevelAccess As String

LevelAccess = Nz(DFirst("LevelAccess", "TableTeamMembers", "UserNameField='" + Environ$("username")) + "'", "")

If LevelAccess = "Administrator" Or "Admin/Supervisor" Then GoTo Endit
End If

The error I'm getting is

Compile error:

End If without block If

Can you see any problems where I have changed the form.

I am putting this into a module just for info if it helps.

many Thanks

Tim
 
Héhé problem is here:
If LevelAccess = "Administrator" Or "Admin/Supervisor" Then GoTo Endit
End If


If "if" and "Then" are on the same line, you have not to add a "End If".
Delete the "End If"
 
So Close

I am now getting error:

Run-Time error '3075':

Syntax error in string in query expression 'Employee=29836719

Again I have altered it a bit just to make it inline with my tables and fields. When I went to debug it stopped at

LevelAccess = Nz(DFirst("LevelAccess", "TeamMembers", "Employee='" + Environ$("username")) + "'", "")


Many Thanks

Tim
 
Ho there is a mistake, this must be:
LevelAccess = Nz(DFirst("LevelAccess", "TableTeamMembers", "UserNameField='" + Environ$("username") + "'"), "")


 
We are slowly edging there

Now I have error

Run-time error '62506'

Data type mismatch in criteria expression.

Code looks like this on my screen

Dim LevelAccess As String

LevelAccess = Nz(DFirst("LevelAccess", "TeamMembers", "Employee='" + Environ$("username") + "'"), "")

If LevelAccess = "Administrator" Or "Admin/Supervisor" Then GoTo Endit

I wish I could work out these things like you guys seem to have the nack to.

Cheers

tim
 
What is the data type of your Employee field ?

If numeric make corresponding change...
 
It is a number. I Have changed the
Dim LevelAccess As String

to

Dim LevelAccess As Long

But it is still giving out the error

AAAAAAAAHHHHHHHHHHHHHHH!!

Right I feel better and more focused now I have releived all that stress.

I have spent all day trying to do this and I can feel it's almost there

Is what I put above correct or not?

 
I don't think this is correct.

"LevelAccess" field is a string data type isn't it ?
And you put a field record typed as string into a long.
Explain me how this works ? :)
 
The LevelAccess field is text and Employee is a long integer number. How to change the settings to work with these I don't know i just took a guess and changed string.
 
This should work:
Dim LevelAccess As String
LevelAccess = DFirst("LevelAccess", "TableTeamMembers", "UserNameField=" + Environ$("username"))
 
What a star.

It works like a charm.

THANKYOU!!

Have a star
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top