Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > Pro VB.NET 2002/2003
|
Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 27th, 2014, 07:14 PM
Registered User
 
Join Date: Dec 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default color test

I know this is an old issue but this is how I handled it. On logon I retrieve the users access type from a table and open my next form. when the form loads button colors are set to disable the use of buttons that the user does not have access to. then when they click the button i test for the disabled color and if the button has that color set it simply exits the sub. In doing it this way the hover colors etc still work, but when clicked on it simply does nothing.

'Form Load event
Private Sub Form_Load()
Dim rs As Recordset
Dim lngLGrey As Long, lngDGrey As Long
lngLGrey = RGB(120, 120, 120)
lngDGrey = RGB(60, 60, 60)
Set rs = CurrentDb.OpenRecordset("Users", dbOpenSnapshot, dbReadOnly)

rs.FindFirst "UserName='" & LCase(Environ$("UserName")) & "'"

Select Case rs!UserType
Case 1

Me.btnReg.ForeColor = lngLGrey
Me.btnReg.BackColor = lngDGrey

Me.btnAdmin.ForeColor = lngLGrey
Me.btnAdmin.BackColor = lngDGrey

Case 2

Me.btnInstructor.ForeColor = lngLGrey
Me.btnInstructor.BackColor = lngDGrey

Me.btnAdmin.ForeColor = lngLGrey
Me.btnAdmin.BackColor = lngDGrey

Case 3

Me.btnAdmin.ForeColor = lngLGrey
Me.btnAdmin.BackColor = lngDGrey

Case 4


Case Else

Me.btnInstructor.ForeColor = lngLGrey
Me.btnInstructor.BackColor = lngDGrey

Me.btnReg.ForeColor = lngLGrey
Me.btnReg.BackColor = lngDGrey

Me.btnAdmin.ForeColor = lngLGrey
Me.btnAdmin.BackColor = lngDGrey
GoTo Invalid
End Select
Exit Sub
Invalid:
Dim LResponse As Integer
LResponse = MsgBox("Invalid UserType", vbOKOnly, "Invalid Access")

End Sub

'button click event
Private Sub btnAdmin_Click()
If Me.btnReg.ForeColor = RGB(120, 120, 120) Then Exit Sub
DoCmd.OpenForm "Admin"
End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
re: color change jack_in_black ASP.NET 2.0 Professional 0 July 11th, 2006 07:24 AM
TD Color Change echovue Javascript How-To 1 March 3rd, 2006 03:40 AM
how to change all control color ashish2001mca .NET Framework 2.0 1 February 23rd, 2005 12:47 AM
change background color of toolbar control myth12345 VB How-To 1 January 6th, 2005 12:25 AM
Color change possability? rolandatem VB How-To 2 November 19th, 2004 03:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.