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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help on writing expression/vb code

Status
Not open for further replies.

AccessDevJunior

Programmer
Apr 14, 2004
81
0
0
GB
Hya,

I have a access form where i would like certain user's restricted from opening.

I do not tend to use much expressions in my databases
and so i have not much experience, basically what i want is if a particular user trys to open form and their username dosnt match up with the list of usernames in table the Event is cancelled. If the username does match the Event will continue.

IF [UserName] IsNot "abc" Cancell Event

Could anyone help me with this?
 
Where is the user name derived from? a Table or Access built in security?

G.
 
You could build a table of authorized users, then use the following code in the click event of a command button...

Private Sub cmdEnter_OnClick()
Dim strName As String
strName = InputBox("Enter Login ID")
If IsNull(DLookup("Name","tblUsers","Name = '" & strName & "'")) Then
MsgBox "Unauthorized user", vbCritical + vbOkOnly, "Access Denied"
Else
Enter code necessary to allow access
End If
End Sub

Or, use the structure I described in thread 702-829870.

Randy
 
thankyou for you your responses

I am wanting to create a table with a list of UserNames that are allowed access the form
 
Yes, thankyou that was exactly what i needed, just responding to 'grumbledook'.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top