A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Setting control properties via code



 
 
Thread Tools Display Modes
  #1  
Old January 5th, 2008, 07:41 PM posted to microsoft.public.access.forms
tsison7
external usenet poster
 
Posts: 69
Default Setting control properties via code

I want to turn the visible property of a control button on or off depending
on who's logged in (ie. Administrator, Salesperson etc).

I think I would enter the code to run when that form is opened but I'm
having trouble with how to write the code.

--
TIA
  #2  
Old January 6th, 2008, 06:24 PM posted to microsoft.public.access.forms
Ken Snell \(MVP\)
external usenet poster
 
Posts: 2,506
Default Setting control properties via code

Use the form's Load event to run code similar to this:

Private Sub Form_Load()
' you can use a function to get the user name -- not sure how you're doing
that
' in your specific situation, so I've just put a "text string"
' ("WhatTheUserNameIs") here for now
Select Case "WhatTheUserNameIs"
Case "Administrator"
Me.CommandButtonName.Visible = True
Case "Salesperson", "Clerical"
Me.CommandButtonName.Visible = False
Case Else
Me.CommandButtonName.Visible = False
End Select
End Sub

--

Ken Snell
MS ACCESS MVP


"tsison7" wrote in message
...
I want to turn the visible property of a control button on or off depending
on who's logged in (ie. Administrator, Salesperson etc).

I think I would enter the code to run when that form is opened but I'm
having trouble with how to write the code.

--
TIA



 




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:54 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.