Solved

Procedure to Make Button Visible and Place on Screen based on variable

Posted on 2011-02-18
5
330 Views
Last Modified: 2012-05-11
I've designed a form with a number of buttons.  I need to make the button visible based on a user's security level.  I'm in the process of building the code that makes the buttons visible and places then on the screen:

If rs![FunctionName] = "Contact Management" Then
    Me.btnContactManagement.Visible = True
    Me.lblContactManagement.Visible = True
    Me.btnContactManagement.Left = 1440 * sLeftMargin
    Me.lblContactManagement.Left = 1440 * (sLeftMargin + 0.25)
    Me.btnContactManagement.Top = 1440 * sTopMargin
    Me.lblContactManagement.Top = 1440 * (sTopMargin + 0.25)
    sTopMargin = sTopMargin + 0.3
End if

Since I've consistently named the buttons and their lables, is there a way to build this in a procedure, such as:

If rs![FunctionName] = "Contact Management" Then
    Call Setup_Buttons("ContactManagement",sLeftMargin,sTopMargin)
End if

I guess the procedure would look something like this:

Private Sub Setup_Buttons(strObjectName As String, sLeft As Single, sTop As Single)

'Make sure you don't re-place button if it is already visible.
If Me."btn" & strObjectName.Visible = False
    Me."btn" & strObjectName.Visible = True
    Me."lbl" & strObjectName.Visible = True
    Me."btn" & strObjectName.Left = 1440 * sLeft
    Me."lbl" & strObjectName.Left = 1440 * (sLeft + 0.25)
    Me."btn" & strObjectName.Top = 1440 * sTop
    Me."lbl" & strObjectName.Top = 1440 * (sTop + 0.25)
    sTopMargin = sTopMargin + 0.3
End if
End Sub

Perhaps there's a function that I need to incorporate to enable me to work with the buttons and labels through variables.  Thanks in advance for your assistance, and let me know if you need any further clarification.
0
Comment
Question by:dhjensen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:dhjensen
ID: 34930364
For what it's worth, I just discovered that apparently "sTop" is a MS Access reserve word.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 34930372
use this format


Private Sub Setup_Buttons(strObjectName As String, sLeft As Single, sTop As Single)

'Make sure you don't re-place button if it is already visible.
If Me("btn" & strObjectName).Visible = False then
    Me("btn" & strObjectName).Visible = True
    Me("lbl" & strObjectName).Visible = True
    Me("btn" & strObjectName).Left = 1440 * sLeft
    Me("lbl" & strObjectName).Left = 1440 * (sLeft + 0.25)
    Me("btn" & strObjectName).Top = 1440 * sTop
    Me("lbl" & strObjectName).Top = 1440 * (sTop + 0.25)
    sTopMargin = sTopMargin + 0.3
End if
End Sub

Open in new window

0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34930379
oh yes, it means Stop > halt the codes


Private Sub Setup_Buttons(strObjectName As String, sLeft As Single, vTop As Single)

'Make sure you don't re-place button if it is already visible.
If Me("btn" & strObjectName).Visible = False then
    Me("btn" & strObjectName).Visible = True
    Me("lbl" & strObjectName).Visible = True
    Me("btn" & strObjectName).Left = 1440 * sLeft
    Me("lbl" & strObjectName).Left = 1440 * (sLeft + 0.25)
    Me("btn" & strObjectName).Top = 1440 * vTop
    Me("lbl" & strObjectName).Top = 1440 * (vTop + 0.25)
    vTopMargin = vTopMargin + 0.3
End if
End Sub

Open in new window

0
 

Author Comment

by:dhjensen
ID: 34930440
Thanks--seting it up now....
0
 

Author Closing Comment

by:dhjensen
ID: 34930627
Thanks very much--it works great!  Perfect solution!  (And I'll stay away from the Stop reserve word.)  Have a great weekend....
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question