username

krishnanhemanth

Registered User.
Local time
Tomorrow, 01:12
Joined
Jun 12, 2009
Messages
115
hi all

i have a textbox "loginname" on a form that displays the window login name
i use the function =fosusername() to get the user login name...working fine

what i then do is ....
i have a combobox that lists all the usernames-----from a table
i need to compare the value selected from the combobox to the textbox "loginname"

i coded this

If Me.cboEmployee.Value = Me.loginname.Value Then

Me.loginname.Enabled = True
Else
Me.loginname.Enabled = False
MsgBox "login not approved. Please contact your system administrator.", vbCritical, "Restricted Access!"
'APPLICATION.Quit

End If

it dosent seem to work
please help

hemanth
 
Which event have you placed the code in and what doesn't work?
 
in the afterupdate event of the combobox
cboEmployee
 
Ok, and for ther second part of my question - what doesn't work?
 
Just for completeness, try changing the relative "Me." to explicitly refer to the object on the form

e.g.

[Forms]![frmName]![loginname]
 
make sure the Combo is also bound to the username.
it's very common to show the username, but bound to the user ID
 
yes there it is... i have found the problem based on your ideas

the combobox value is bound to the employeeid and not to the employeename

i rectified it and now its rocking

thanks all of you

now another hiccup

all the employeeid also have useraccessno
1 = read and write
2 = read only
3 = add only

how do i use it globally so that depending on the user and his user access no, the permissions are granted accordingly
 
good you solved it :)

you can still bound it to the employeeID if you need and compare:
If Me.cboEmployee.Value = Me.loginname.column(1).Value Then...

Column(0) is the first one
Column(1) is the second one, where the name is


and you can use the other columns to set other permissions as needed.
if you add these columns to the combobox and don't want the user to see them set their ColumnsWidth to 0.
something like: 0;3;0;0;0
this will only show the second column
 

Users who are viewing this thread

Back
Top Bottom