Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 12-30-2003, 12:06 PM   #1
ekta
Registered User
 
Join Date: Sep 2002
Location: United States
Posts: 160
Thanks: 0
Thanked 0 Times in 0 Posts
ekta
Enable/Disable button

Hi:

I have a login form. Every user is assigned a userlevel. It is either 'admin' or 'user'. Once a user logs in successfully frmMain opens and user's userid and userlevel is stored in table, N_tblLocalUser, using append query. frmMain has Administrator button which, I want to be disabled if the userlevel is 'user' and enabled if user level is 'admin'.
This is the code that I have on the Open event of frmMain.

If DLookup("[USERLEVEL]", "N_tblLocalUser", "[USERLEVEL] <> 'admin'") = "user" Then
Me.btnUserMgmt.Enabled = False
Else
Me.btnUserMgmt.Enabled = True
End If

But it is not working. What else do I need to do to make it work?

Thanx
Ekta

ekta is offline   Reply With Quote
Old 12-30-2003, 12:47 PM   #2
WayneRyan
AWF VIP
 
Join Date: Nov 2002
Location: Camarillo, CA
Posts: 7,090
Thanks: 6
Thanked 57 Times in 55 Posts
WayneRyan is a jewel in the rough WayneRyan is a jewel in the rough WayneRyan is a jewel in the rough
Ekta,

I don't know where you stored their UserID when they
logged in, but something like this should do:

Code:
If Nz(DLookup("[USERLEVEL]", "N_tblLocalUser", "[USERID] = " & Me.UserID), "") <> "Admin" Then
  Me.btnUserMgmt.Enabled = False
Else
  Me.btnUserMgmt.Enabled = True
End If
Wayne
WayneRyan is offline   Reply With Quote
Old 12-30-2003, 01:32 PM   #3
ekta
Registered User
 
Join Date: Sep 2002
Location: United States
Posts: 160
Thanks: 0
Thanked 0 Times in 0 Posts
ekta
Thanx for replying Wayne:

This does not work. I am attaching the db. If you could please take a look at it.

Ekta
Attached Files
File Type: zip admin2k.zip (31.8 KB, 164 views)

ekta is offline   Reply With Quote
Old 12-30-2003, 04:09 PM   #4
WayneRyan
AWF VIP
 
Join Date: Nov 2002
Location: Camarillo, CA
Posts: 7,090
Thanks: 6
Thanked 57 Times in 55 Posts
WayneRyan is a jewel in the rough WayneRyan is a jewel in the rough WayneRyan is a jewel in the rough
ekta,

Your weren't using the DLookups properly.
You have code in that deletes all records from the user's table!
You lost all of your values when you closed your form.

I added global variables (see modules) for the user and level.
When the user enters password, I filled in the globals. The
next form uses the globals to enable/disable the button.

It's still a little rough, but with some work it'll be OK.

Wayne
Attached Files
File Type: zip ekta.zip (51.2 KB, 164 views)
WayneRyan is offline   Reply With Quote
Old 12-30-2003, 04:52 PM   #5
ekta
Registered User
 
Join Date: Sep 2002
Location: United States
Posts: 160
Thanks: 0
Thanked 0 Times in 0 Posts
ekta
Hi Wayne:

It doesn't seem to be working. I see that you added 2 users in N_tblLocalUser. All my users are saved in N_tblPassword. Once they login in successfully their UserID and UserLevel are stored in N_tblLocalUser using append query. N_tblLocalUser is used to temporarily store the user logged in the db. I want to use this to enable/disable the button. When they logout of the database the user is deleted from N_tblLocalUser using delete query.

Ekta
ekta is offline   Reply With Quote
Old 12-30-2003, 04:55 PM   #6
WayneRyan
AWF VIP
 
Join Date: Nov 2002
Location: Camarillo, CA
Posts: 7,090
Thanks: 6
Thanked 57 Times in 55 Posts
WayneRyan is a jewel in the rough WayneRyan is a jewel in the rough WayneRyan is a jewel in the rough
ekta,

True, but I only had part of the database. Essentially I was
just trying to show you how the DLookups can be used.

Wayne
WayneRyan is offline   Reply With Quote
Old 12-31-2003, 03:04 AM   #7
Oldsoftboss
AWF VIP
 
Oldsoftboss's Avatar
 
Join Date: Oct 2001
Location: in the shed
Posts: 2,504
Thanks: 0
Thanked 57 Times in 49 Posts
Oldsoftboss will become famous soon enough
I dont use Dlookups... I di it this way

HTH
Dave
Attached Files
File Type: zip db1.zip (61.2 KB, 213 views)

__________________
Apathy is on the increase, but who cares.

Imagine if there were no hypothetical questions

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Oldsoftboss is offline   Reply With Quote
Old 12-31-2003, 07:57 AM   #8
ekta
Registered User
 
Join Date: Sep 2002
Location: United States
Posts: 160
Thanks: 0
Thanked 0 Times in 0 Posts
ekta
Thanx Wayne and Dave. I got it to work.

ekta is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump




All times are GMT -8. The time now is 05:19 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World