<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener("load", function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <iframe src="http://www.blogger.com/navbar.g?targetBlogID=34083602&amp;blogName=LEARN+MS-ACCESS+TIPS+AND+TRICKS&amp;publishMode=PUBLISH_MODE_FTP&amp;navbarType=BLUE&amp;layoutType=CLASSIC&amp;searchRoot=http%3A%2F%2Fblogsearch.google.com%2F&amp;blogLocale=en_US&amp;homepageUrl=http%3A%2F%2Fwww.msaccesstips.com%2F" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" height="30px" width="100%" id="navbar-iframe" allowtransparency="true" title="Blogger Navigation and Search"></iframe> <div></div>
www.msaccesstips.com

LEARN MS-ACCESS TIPS AND TRICKS


International Response Fund

LEARN MS-ACCESS TIPS AND TRICKS

↑ Grab this Headline Animator

Your Ad Here
Friday, April 11, 2008

Transparent Command Button

Command Buttons can be kept hidden on Forms by setting their Transparent or Visible Property to No and make them visible to click, when certain condition is met or when a particular User opens the Form.


For example, when a Form with Data is routed through Networks to different Users (in a Secured Database) for verification, Approval of the contents, different Command Buttons can be created and programmed for each user and make them visible only when the respective User opens the Form or subject to the verified status of Data at lower Rank of Users and so on.


The more popular method in practice, in the above situations, is to disable the Command Button and keep it visible all the time and enable it when required. Making a Button visible or invisible is another way of doing the same thing. We cannot set the Command button's Enabled or Visible Property to No, when the Button is active. We must shift the Focus from the Button to some other Control before setting the above properties to No through VBA Code.


The Transparent Property setting doesn't have this restriction. You can make the Command Button visible or invisible by setting the value to No (for Normal View) and Yes to make it disappear.


This method has some side effects. If the User knows exactly from where the Command Button disappeared then he can click on the same spot and the transparent Command Button will respond with its programmed action. But we can trick the User by changing the Button's invisible run time parking position to a different location by increasing or decreasing the Left Property value after saving the original value into a Module level Global Variable. When it is time to restore the Button to its normal shape on the original spot we can use the Left Property value saved in the Global Variable.


Here, we are going to use the Transparent Command Button differently for designing and running a Main Switchboard Menu.


  1. Design a Table using the Structure shown below and enter few sample records given in them.


  2. Sample Table Image


  3. Design a Tabular Form using the above table using the Form Wizard and save it with the name DataFiles.


  4. Open the Form in Design view. Keep the ID and Desc fields and remove others. Keep Shift Key down and Click on both Fields to select them together. Or Click outside the Fields and drag the mouse over to select them both.


  5. Display the Property Sheet (View --> Properties) and change the Following Property Values.



  6. · Enabled = No
    · Locked = Yes
    · Top = 0.0417”
    · Height = 0.1771”
    · Back Style = Normal
    · Back Color = -2147483633
    · Special Effect = Raised
    · Border Style = Solid
    · Border Color = 0
    · Border Width = Hairline
    · Fore Color = 0


  7. Select View Menu and remove check mark from Form Header/Footer Option. Select Yes to the Warning message to delete the Header/Footer Sections from the Form.


  8. Click on the top left corner of the Form to de-select all controls and select the Form. Display the Form Property Sheet (View - -> Properties) and change the following Form Property Values.



  9. · Form Width = 2.5417"
    · Default view = Continuous Forms
    · Views Allowed = Form
    · Allow Edits = No
    · Allow Additions = No
    · Allow Deletions = No
    · Record Selectors = No
    · Navigation Buttons = No
    · Dividing Lines = No
    · Scrollbars = No
    · Border Style = None
    · Control Box = No
    · Min Max Buttons = None
    · Close Button = No
    · Whats this Button = No
    · Allow Design Changes = Design View Only


  10. Draw a Command Button about the size of both Field widths put together somewhere below the Fields so that we can modify the properties of the Command Button and place it over both the Fields in transparent state.



  11. Form Design-1 Image

  12. Select the Command Button and display the Property Sheet. Change the following Property Values:



  13. · Name = cmdMenu
    · Transparent = Yes
    · Height = 0.1771"


  14. Click on the On Click Property and select Event Procedure from the Drop down List and click on the Build () button to open the Form’s VBA Module.


  15. Here we can write code to test the ID Value of the record clicked by the User and open the Form corresponding to that Number.


    The VBA Code for a simple method to test and Open the Form corresponding to the ID number of the record clicked is given below.


  16. Copy and paste the following Code into the VBA Module of the DataFiles Form and save the Form.



  17. Private Sub cmdMenu_Click()
    Dim IDNumber As Integer, strForm As String

    IDNumber = Me![ID]
    strForm = ""
    Select Case IDNumber
    Case 1
    strForm = "CRREQ_MASTER"
    Case 2
    strForm = "Dept_Codes"
    Case 3
    strForm = "Branch"
    End Select
    If Len(strForm) > 0 Then
    DoCmd.OpenForm strForm, acNormal
    End If
    End Sub


    You can use a better method, more powerful and re-usable one that I have explained with VBA Code in an earlier Article with the Title: Opening Access Forms. I recommend that you read that Article and the method explained there, which is easy to implement in any of your Projects. The sample table that we have seen at the beginning of this Article is taken from that example with additional fields (Forms, Macro & Type). If the Code given there is used, you can add any number of records in the above table and don’t need to test each ID number as we did in the above code. Besides that you can open a Form directly or run a process, through macros, and at the end of the process open a Form to display the result by setting the value in the Type Field to 0 or 1, when a new record is added to the table.


  18. Drag the Transparent Command Button (or use Ctrl Key with Arrow Key combination in Office 2000, Arrow Key alone in Office 2003, after selecting it) and place it over ID and Desc Fields correctly as shown below.


  19. Form Design-2 Image

  20. Click on the Detail Section of the Form and Display the Property Sheet. Change the Details Section height.


  21. · Detail Section Height = .25”


    The finished design will look like the image given below in normal view. This Form will be used as a Sub-Form on the Control Screen (Main Switchboard) for our Data Files Menu. If you don’t want to show the Serial Numbers appearing at the left, you can set the Visible Property of that field to No.


    Form Design-3 Image

    Open the Main Switchboard Form of your Project (or any Form to try it out) drag and place the above Form on it. I placed the Menu on the sample Form that we have used for the Colorful Command Buttons Article.
  22. Click on the Sub-Form, Display the Property Sheet and change the following Property Values:




· Special Effect = Flat
· Border Style = Transparent



Data Files' Menu on Main Switchboard

The instances of the same Transparent Command Button now appears on top of each record in the Form and will respond to the Clicks on them. We can check the Value of the record on which the click received and open the Form corresponding to that record ID number.


When you add more records to the menu table they will automatically appear on the menu without any modifications to the design.


Try the Menu by adding Form Names already available in your Project replacing the ones that appears in the Code.



Selecting Office Assistant
Office Assistant with Check Box Menu
Msgbox with Options Menu
Who Changed the Data
Progress Counter

Labels:

0 Comments:

Post a Comment

Note:Comments subject to Review by Blog Author before displaying.

Links to this post:

Create a Link

<< Home


Creative Commons License
Learn MS-Access Tips and Tricks by msaccesstips.com is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 India License.



This Page is best viewed with 1280 x 1024 Resolution

   FEATURED LINKS
SITEMAP
Command Button Animation
3D Headings on Forms
MsgBox & Office Assistant
Reminder Ticker
MS-Access & E-Mails
Automated E-Mail Alerts
MsgBox with Options Menu
Colorful Command Buttons
Configure Lotus Notes
Alerts through Network
Running this site has become a costly affair as the revenue from Ads is not sufficient to support it. If you find these pages informative & useful and would like to extend a helping hand, then please do it here.





Link Back to us with this Button

Learn MS-Access

Copy and Paste this HTML Code in your Webpage


Add to Technorati Favorites

Programming Blogs - Blog Catalog Blog Directory
Powered by FeedBurner
Add to Google

Software
Computers blogs
TopOfBlogs




AddMe - Search Engine Optimization Submit Your Site Free!
Go BlogZ Ave Blogs
eBlogzilla Changing LINKS
LS Blogs Blogarama
blog search directory BlogUniverse
Find Blogs in Directory RSS Directory
blogskinny.com ShowcaseBlogs.com
Amfibi

Search Engine Optimization and SEO Tools
Dmegs Web Directory Takeaway for Sale Businesses For Sale
Free Submission Directory Free site submission

Free Listing
 





Free Page Rank Checker

AddThis Social Bookmark Button

Enter your email address:

Delivered by FeedBurner



Top Blogs


Microsoft Access is the Jewell among MS-Office suite of Applications. Its Security features are excellent and works fine in Network environment. MS-Access can link/upload data from any Data Source. Applications that you design should be user-friendly and visually pleasing too. Here I would like to share my experience in Microsoft Access Programming with you and I am sure that you will find them interesting too.

My Photo
Name: Ramachandran Pillai
Location: Cochin, India

I am not an Access Guru and not through MS-Access yet. More to learn and I don’t think that aspect has any end because others have their own style of using this tool. We can learn lot more tricks, other than what we already know, from others too. My programming skills in COBOL, BASIC, Turbo-C, dBase, FoxPro, Visual Basic & Basic HTML attained through self-learning. I wrote my first COBOL Program in 1975 for ICL1901, 3rd Generation Main Frame Computer. Worked as a Computer Operator (NCR VRX8555 Mainframe Machine upto 1990) with M/s. Y.B.A. Kanoo, Saudi Arabia. Started using MS-Access Ver.2 in 1996, when dBase III+ and Foxbase (later version Foxpro) were my favorite DBMS. During Last 13 Year period I have developed more than 45 In-House Applications (medium & small) under MS-Access for our Organization, a leading Automotive Company in Oman. All the Applications are fully Secured and runs under Windows Network. It is my pleasure to share my experience with others. Anything interesting that you would like to share with me, please do. My E-mail Address: aprpillai@msaccesstips.com


If you need a Demo of any of the Topic explained here, send me an E-mail to: aprpillai@msaccesstips.com
with the Topic Description, I shall try to send a sample database to you.


Access Tips | Email | Reports | Report Tricks | Graphs | Forms | Menus | Animation | Security | Internet | How TOs | Linking | Query | Progress Meter | Alerts | Process Tips | Access Functions |




Site Designed by:www.msaccesstips.com