1d6df Disenabling buttons base on User
Sign Up |  Live StatsLive Stats    Articles 37,305| Comments 176,996| Members 19,397, Newest birinder| Online 437
Home Contact
 (Forgotten?): 
    Sikhism
    For best SPN experience, use Firefox Internet Browser!


                                                                   Your Banner Here!    




Disenabling buttons base on User

Our Donation Goal : Why Donate? : Donate Today! : Donate Anonymously (ਗੁਪਤ) : Our Family of Supporters
Goal this month: 500 USD, Received: 100 USD (20%)
Please Donate...
     
Related Topics...
Thread Thread Starter Forum Replies Last Post
Sorting Buttons on Form Coleman Information Technology 3 28-Jul-2006 08:32 AM
Disenabling a button... dcash45 Information Technology 3 28-Jul-2006 08:21 AM
new style buttons Wuelf Information Technology 1 28-Jul-2006 08:19 AM
Single User DB thinks there is another user... BetoWing Information Technology 3 28-Jul-2006 08:18 AM
Creating buttons Msdplove Information Technology 1 05-Nov-2005 12:48 PM


Tags
disenabling, buttons, base, user
Reply Post New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!
  #1 (permalink)  
Old 28-Jul-2006, 08:21 AM
dcash45's Avatar dcash45
Guest
 
Posts: n/a
   
   
Disenabling buttons base on User

  Donate Today!   Email to Friend  Tell a Friend   Show Printable Version  Print   Contact sikhphilosophy.net Administraion for any Suggestions, Ideas, Feedback.  Feedback  

Register to Remove Advertisements
Hello I want to open a form and enable or disenable the buttons base on what
type of user is login.

I have a login form that goes to two different switchboard forms base on the
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/information-technology/11469-disenabling-buttons-base-on-user.html
type of user (manage or employee). But both switchboard calls on some of the
same form; like my states form. This form has the buttons of Add, Update,
Delete, and so on. The manager would have the right to do all of the
functions but I want the employees to only have the right to just Update. So
if an employee login and opening the states form I want the Add and Delete
button to be disenable and if a manage login all the buttons stay enable.
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11469

So I would like to know does anyone know how to design is code because I am
having some problems designing it.

Thank you,



Do share your immediate thoughts or reactions on this issue? We value your views! Login Now! or Sign Up Today! to share your views with us.. Gurfateh!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 28-Jul-2006, 08:21 AM
Rob Parker's Avatar Rob Parker
Guest
 
Posts: n/a
   
   
Re: Disenabling buttons base on User

Since you can already determine whether the type of user, I'll assume that
you have a function (IsManager in the following lines) that returns True if
the user is a manager.

In the Open event of your form(s), you can enable/disable various controls
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11469
as follows:

Me.MyAddButtonName.Enabled = IsManager

You can also set the form properties to allow edits/additions/deletes in the
same fashion:
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11469

Me.AllowEdits = IsManager

HTH,

Rob


"dcash45" wrote in message
news:F56D15D9-ABC1-48F4-AAC4-B61306A775F6@microsoft.com...
> Hello I want to open a form and enable or disenable the buttons base on
> what
> type of user is login.
>
> I have a login form that goes to two different switchboard forms base on
> the
> type of user (manage or employee). But both switchboard calls on some of
> the
> same form; like my states form. This form has the buttons of Add, Update,
> Delete, and so on. The manager would have the right to do all of the
> functions but I want the employees to only have the right to just Update.
> So
> if an employee login and opening the states form I want the Add and Delete
> button to be disenable and if a manage login all the buttons stay enable.
>
> So I would like to know does anyone know how to design is code because I
> am
> having some problems designing it.
>
> Thank you,
>



Reply With Quote
  #3 (permalink)  
Old 28-Jul-2006, 08:21 AM
dcash45's Avatar dcash45
Guest
 
Posts: n/a
   
   
Re: Disenabling buttons base on User

Hi Rob thanks for replying but Im still a little lost. Yos said I should have
a IsManager function but I didnt have one. So I designing it right now but I
dont really know what I should include.

"Rob Parker" wrote:

> Since you can already determine whether the type of user, I'll assume that
> you have a function (IsManager in the following lines) that returns True if
> the user is a manager.
>
> In the Open event of your form(s), you can enable/disable various controls
> as follows:
>
> Me.MyAddButtonName.Enabled = IsManager
>
> You can also set the form properties to allow edits/additions/deletes in the
> same fashion:
>
> Me.AllowEdits = IsManager
>
> HTH,
>
> Rob
>
>
> "dcash45" wrote in message
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11469
> news:F56D15D9-ABC1-48F4-AAC4-B61306A775F6@microsoft.com...
> > Hello I want to open a form and enable or disenable the buttons base on
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11469
> > what
> > type of user is login.
> >
> > I have a login form that goes to two different switchboard forms base on
> > the
> > type of user (manage or employee). But both switchboard calls on some of
> > the
> > same form; like my states form. This form has the buttons of Add, Update,
> > Delete, and so on. The manager would have the right to do all of the
> > functions but I want the employees to only have the right to just Update.
> > So
> > if an employee login and opening the states form I want the Add and Delete
> > button to be disenable and if a manage login all the buttons stay enable.
> >
> > So I would like to know does anyone know how to design is code because I
> > am
> > having some problems designing it.
> >
> > Thank you,
> >

>
>
>

Reply With Quote
  #4 (permalink)  
Old 28-Jul-2006, 08:21 AM
Rob Parker's Avatar Rob Parker
Guest
 
Posts: n/a
   
   
Re: Disenabling buttons base on User

In your first post, you said " ... goes to two different switchboard forms
base on the type of user (manage or employee)." Therefore, you already have
some means of identifying which type of user is logged in. How are you
doing that? Please post the code you are using for that, and we'll go from
there.

Rob

"dcash45" wrote in message
news:8D10EBCA-EE89-46B6-9A8F-8E5A2DE86B0A@microsoft.com...
> Hi Rob thanks for replying but Im still a little lost. Yos said I should
> have
> a IsManager function but I didnt have one. So I designing it right now
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11469
> but I
> dont really know what I should include.
>
> "Rob Parker" wrote:
>
>> Since you can already determine whether the type of user, I'll assume
>> that
>> you have a function (IsManager in the following lines) that returns True
>> if
>> the user is a manager.
>>
>> In the Open event of your form(s), you can enable/disable various
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11469
>> controls
>> as follows:
>>
>> Me.MyAddButtonName.Enabled = IsManager
>>
>> You can also set the form properties to allow edits/additions/deletes in
>> the
>> same fashion:
>>
>> Me.AllowEdits = IsManager
>>
>> HTH,
>>
>> Rob
>>
>>
>> "dcash45" wrote in message
>> news:F56D15D9-ABC1-48F4-AAC4-B61306A775F6@microsoft.com...
>> > Hello I want to open a form and enable or disenable the buttons base on
>> > what
>> > type of user is login.
>> >
>> > I have a login form that goes to two different switchboard forms base
>> > on
>> > the
>> > type of user (manage or employee). But both switchboard calls on some
>> > of
>> > the
>> > same form; like my states form. This form has the buttons of Add,
>> > Update,
>> > Delete, and so on. The manager would have the right to do all of the
>> > functions but I want the employees to only have the right to just
>> > Update.
>> > So
>> > if an employee login and opening the states form I want the Add and
>> > Delete
>> > button to be disenable and if a manage login all the buttons stay
>> > enable.
>> >
>> > So I would like to know does anyone know how to design is code because
>> > I
>> > am
>> > having some problems designing it.
>> >
>> > Thank you,
>> >

>>
>>
>>



Reply With Quote
  #5 (permalink)  
Old 28-Jul-2006, 08:21 AM
dcash45's Avatar dcash45
Guest
 
Posts: n/a
   
   
Re: Disenabling buttons base on User

I have a user type table thats keeps the usertypeId & usertypename. I have
another that call login which links the userID & the usertypeID together. So
in the form login the code I use is .....

Sub procLogin(UserName As String, Pwd As String)
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11469
On Error GoTo LoginErrors

' Declare variables
Dim dbsConnection As Database
Dim rsUser As Recordset
Dim dbstring As String
Dim sqlString As String
Dim thisUser As String
Dim temp As Integer

' DFD 1.3 (DBU1)
' Connect to database by calling a module procedure.
Set dbsConnection = procConnectToDatabase()

' Define and open the table
sqlString = "tblLogin"
Set rsUser = dbsConnection.OpenRecordset(sqlString)

sqlString = "SELECT tblLogin.UserID, tblLogin.Username,
tblLogin.Password, tblLogin.UserTypeID" & _
" FROM tblLogin" & _
" WHERE (((tblLogin.Username)='" & UserName & "') AND
((tblLogin.Password)='" & Pwd & "'));"



' Send the SQL Query to the database connection
Set rsUser = dbsConnection.OpenRecordset(sqlString)

' if eof then user was found with that username/ password
If rsUser.EOF Then
temp = MsgBox("Invalid Login.", vbExclamation, "Can't Log In")
' DFD 1.5
' close recordsets and database connection
rsUser.Close
'Call procCloseDatabase(dbsConnection)
Exit Sub

'DFD 1.6
Else
' User found so find out what type they are and display appropriate GUI
UserTypeID = rsUser!UserTypeID

' Close Login GUI
DoCmd.Close

Select Case UserTypeID

Case 1: ' Manager logged in, open Manager Switchboard GUI
DoCmd.OpenForm "frmManagerSwitchboard", , , , , , rsUser!userID
Case 2: ' Employee switchboard Logged In, open Employee switchboard GUI
DoCmd.OpenForm "frmEmployeeSwitchboard", , , , , , rsUser!userID
Case 3: ' Customer switchboard Logged In, open Customer switchboard GUI
DoCmd.OpenForm "frmCustomerSwitchboard", , , , , , rsUser!userID
Case Else: procDisplayMessage ("You are not authorized to login")

End Select


so now after the user is login a switchboard display depending the type of
user and in this switchboard I have buttons that opening up other forms. Now
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11469
the manager switcbhoard and the employee switchboard is different but the 2
have a button that opens up the form states...now heres where I get lost. I
dont know how to enable or disenable the buttons base on the user.
Reply With Quote
  #6 (permalink)  
Old 28-Jul-2006, 08:21 AM
Rob Parker's Avatar Rob Parker
Guest
 
Posts: n/a
   
   
Re: Disenabling buttons base on User

There are several possible approaches to this problem. The best, or
feasible, one will depend on how the application works after the switchboard
form is opened, and perhaps on whether the application is split, with each
user having their own front-end and a shared back-end datafile. [Note: I'm
assuming from your current code that you are not using Access's built-in
user-level security.]

First off, I suggest using a function based on whether the manager
switchboard was opened, which will work providing the switchboard form is
not closed until the user ends the session. The switchboard can be hidden
when other forms are opened form it (that's a very common practice), and
this will still work. Copy the following into a module, and save the
module - you must give it a different name to that of this function!

Public Function IsManager() As Boolean
Dim i As Integer
IsManager = False
For i = 0 To Forms().Count - 1
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11469
If Forms(i).Name = "frmManagerSwitchboard" Then IsManager = True
Next i
End Function

This returns True or False, depending on whether the frmManagerSwitchboard
is open or not; it uses the fact that a form which is not open is not a
member of the Forms collection. This function will allow the statements I
posted previously to work.

If this doesn't work, post again and we'll explore further alternatives.

HTH,

Rob


"dcash45" wrote in message
news:38C87C06-A8AA-427E-8544-C9D5D27693A7@microsoft.com...
>I have a user type table thats keeps the usertypeId & usertypename. I have
> another that call login which links the userID & the usertypeID together.
> So
> in the form login the code I use is .....
>
> Sub procLogin(UserName As String, Pwd As String)
> On Error GoTo LoginErrors
>
> ' Declare variables
> Dim dbsConnection As Database
> Dim rsUser As Recordset
> Dim dbstring As String
> Dim sqlString As String
> Dim thisUser As String
> Dim temp As Integer
>
> ' DFD 1.3 (DBU1)
> ' Connect to database by calling a module procedure.
> Set dbsConnection = procConnectToDatabase()
>
> ' Define and open the table
> sqlString = "tblLogin"
> Set rsUser = dbsConnection.OpenRecordset(sqlString)
>
> sqlString = "SELECT tblLogin.UserID, tblLogin.Username,
> tblLogin.Password, tblLogin.UserTypeID" & _
> " FROM tblLogin" & _
> " WHERE (((tblLogin.Username)='" & UserName & "') AND
> ((tblLogin.Password)='" & Pwd & "'));"
>
>
>
> ' Send the SQL Query to the database connection
> Set rsUser = dbsConnection.OpenRecordset(sqlString)
>
> ' if eof then user was found with that username/ password
> If rsUser.EOF Then
> temp = MsgBox("Invalid Login.", vbExclamation, "Can't Log In")
> ' DFD 1.5
> ' close recordsets and database connection
> rsUser.Close
> 'Call procCloseDatabase(dbsConnection)
> Exit Sub
>
> 'DFD 1.6
> Else
> ' User found so find out what type they are and display appropriate GUI
> UserTypeID = rsUser!UserTypeID
>
> ' Close Login GUI
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11469
> DoCmd.Close
>
> Select Case UserTypeID
>
> Case 1: ' Manager logged in, open Manager Switchboard GUI
> DoCmd.OpenForm "frmManagerSwitchboard", , , , , , rsUser!userID
> Case 2: ' Employee switchboard Logged In, open Employee switchboard GUI
> DoCmd.OpenForm "frmEmployeeSwitchboard", , , , , ,
> rsUser!userID
> Case 3: ' Customer switchboard Logged In, open Customer switchboard GUI
> DoCmd.OpenForm "frmCustomerSwitchboard", , , , , ,
> rsUser!userID
> Case Else: procDisplayMessage ("You are not authorized to login")
>
> End Select
>
>
> so now after the user is login a switchboard display depending the type of
> user and in this switchboard I have buttons that opening up other forms.
> Now
> the manager switcbhoard and the employee switchboard is different but the
> 2
> have a button that opens up the form states...now heres where I get lost.
> I
> dont know how to enable or disenable the buttons base on the user.



Reply With Quote
  #7 (permalink)  
Old 28-Jul-2006, 08:21 AM
dcash45's Avatar dcash45
Guest
 
Posts: n/a
   
   
Re: Disenabling buttons base on User

Thanks Rob I will work on it and let you know if this helps me out.

"Rob Parker" wrote:

> There are several possible approaches to this problem. The best, or
> feasible, one will depend on how the application works after the switchboard
> form is opened, and perhaps on whether the application is split, with each
> user having their own front-end and a shared back-end datafile. [Note: I'm
> assuming from your current code that you are not using Access's built-in
> user-level security.]
>
> First off, I suggest using a function based on whether the manager
> switchboard was opened, which will work providing the switchboard form is
> not closed until the user ends the session. The switchboard can be hidden
> when other forms are opened form it (that's a very common practice), and
> this will still work. Copy the following into a module, and save the
> module - you must give it a different name to that of this function!
>
> Public Function IsManager() As Boolean
> Dim i As Integer
> IsManager = False
> For i = 0 To Forms().Count - 1
> If Forms(i).Name = "frmManagerSwitchboard" Then IsManager = True
> Next i
> End Function
>
> This returns True or False, depending on whether the frmManagerSwitchboard
> is open or not; it uses the fact that a form which is not open is not a
> member of the Forms collection. This function will allow the statements I
> posted previously to work.
>
> If this doesn't work, post again and we'll explore further alternatives.
>
> HTH,
>
> Rob
>
>
> "dcash45" wrote in message
> news:38C87C06-A8AA-427E-8544-C9D5D27693A7@microsoft.com...
> >I have a user type table thats keeps the usertypeId & usertypename. I have
> > another that call login which links the userID & the usertypeID together.
> > So
> > in the form login the code I use is .....
> >
> > Sub procLogin(UserName As String, Pwd As String)
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11469
> > On Error GoTo LoginErrors
> >
> > ' Declare variables
> > Dim dbsConnection As Database
> > Dim rsUser As Recordset
> > Dim dbstring As String
> > Dim sqlString As String
> > Dim thisUser As String
> > Dim temp As Integer
> >
> > ' DFD 1.3 (DBU1)
> > ' Connect to database by calling a module procedure.
> > Set dbsConnection = procConnectToDatabase()
> >
> > ' Define and open the table
> > sqlString = "tblLogin"
> > Set rsUser = dbsConnection.OpenRecordset(sqlString)
> >
> > sqlString = "SELECT tblLogin.UserID, tblLogin.Username,
> > tblLogin.Password, tblLogin.UserTypeID" & _
> > " FROM tblLogin" & _
> > " WHERE (((tblLogin.Username)='" & UserName & "') AND
> > ((tblLogin.Password)='" & Pwd & "'));"
> >
> >
> >
> > ' Send the SQL Query to the database connection
> > Set rsUser = dbsConnection.OpenRecordset(sqlString)
> >
> > ' if eof then user was found with that username/ password
> > If rsUser.EOF Then
> > temp = MsgBox("Invalid Login.", vbExclamation, "Can't Log In")
> > ' DFD 1.5
> > ' close recordsets and database connection
> > rsUser.Close
> > 'Call procCloseDatabase(dbsConnection)
> > Exit Sub
> >
> > 'DFD 1.6
> > Else
> > ' User found so find out what type they are and display appropriate GUI
> > UserTypeID = rsUser!UserTypeID
> >
> > ' Close Login GUI
> > DoCmd.Close
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11469
> >
> > Select Case UserTypeID
> >
> > Case 1: ' Manager logged in, open Manager Switchboard GUI
> > DoCmd.OpenForm "frmManagerSwitchboard", , , , , , rsUser!userID
> > Case 2: ' Employee switchboard Logged In, open Employee switchboard GUI
> > DoCmd.OpenForm "frmEmployeeSwitchboard", , , , , ,
> > rsUser!userID
> > Case 3: ' Customer switchboard Logged In, open Customer switchboard GUI
> > DoCmd.OpenForm "frmCustomerSwitchboard", , , , , ,
> > rsUser!userID
> > Case Else: procDisplayMessage ("You are not authorized to login")
> >
> > End Select
> >
> >
> > so now after the user is login a switchboard display depending the type of
> > user and in this switchboard I have buttons that opening up other forms.
> > Now
> > the manager switcbhoard and the employee switchboard is different but the
> > 2
> > have a button that opens up the form states...now heres where I get lost.
> > I
> > dont know how to enable or disenable the buttons base on the user.

>
>
>

Reply With Quote
  #8 (permalink)  
Old 28-Jul-2006, 08:21 AM
dcash45's Avatar dcash45
Guest
 
Posts: n/a
   
   
Re: Disenabling buttons base on User

Hi from what I can tell it seen to be working but Im still going to test if
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11469
fully to make sure it working the may I want it to...But thanks a whole lot...
Reply With Quote
  #9 (permalink)  
Old 28-Jul-2006, 08:21 AM
Rob Parker's Avatar Rob Parker
Guest
 
Posts: n/a
   
   
Re: Disenabling buttons base on User

  Donate Today!  
You're welcome. And there's no such a thing as too much testing ;-)

Rob

"dcash45" wrote in message
newsC628D66-EF78-44F8-9F14-A1765761F35B@microsoft.com...
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11469
> Hi from what I can tell it seen to be working but Im still going to test
> if
> fully to make sure it working the may I want it to...But thanks a whole
> lot...

Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11469


Reply With Quote
   Click Here to Donate Now!

Support Us!
Become a Promoter!
Gurfateh ji, you can become a SPN Promoter by Donating as little as $10 each month. With limited resources & high operational costs, your donations make it possible for us to deliver a quality website and spread the teachings of the Sri Guru Granth Sahib Ji, to serve & uplift humanity. Every contribution counts. Donate Generously. Gurfateh!
ReplyPost New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!

Bookmarks


(View-All Members who have read this thread : 0
There are no names to display.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Tools Search
Search:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

» Active Discussions
BHOOTS (Ghosts) and...
Today 19:02 PM
94 Replies, 13,742 Views
Textbooks Terming Sikhs...
Today 18:52 PM
13 Replies, 166 Views
Do you believe in...
Today 18:52 PM
175 Replies, 3,607 Views
Map shows world's 'most...
Today 18:12 PM
14 Replies, 189 Views
Friends. A Testimony to...
Today 17:31 PM
3 Replies, 51 Views
Why are There so Many...
By Ishna
Today 17:28 PM
52 Replies, 4,852 Views
Nitnem Gutka - Gurmukhi...
By Ishna
Today 12:27 PM
15 Replies, 16,388 Views
Poetry Corner
Today 12:13 PM
83 Replies, 9,592 Views
Learn Punjabi Yourself...
Today 05:41 AM
15 Replies, 7,617 Views
Sikh Spokesman (ਪੰਜਾਬੀ...
Today 05:32 AM
167 Replies, 4,301 Views
The Great Imp Debate
Today 05:28 AM
32 Replies, 496 Views
Rozana Reports (ਪੰਜਾਬੀ...
Today 05:16 AM
299 Replies, 7,413 Views
Thought of the Moment!
Today 04:01 AM
105 Replies, 4,993 Views
Panjabi
Today 02:14 AM
9 Replies, 208 Views
Fresno Sikh Who Was...
Today 01:30 AM
0 Replies, 55 Views
» Books You Should Read...
Powered by vBadvanced CMPS v3.2.3
All times are GMT +6.5. The time now is 19:28 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2 Copyright © 2004-12, All Rights Reserved. Sikh Philosophy Network


Page generated in 0.62927 seconds with 32 queries
0