Selasa, 05 November 2013

RE: [MS_AccessPros] RE: Dim Variable question

 

Jim-

 

An expression like (ctrl.Tag = "ShowMe") is a logical expression that returns True or False.  So, if the Tag property of the control says "ShowMe", then the Visible property of the control will be set to True.

 

The one problem I see with Bill's example is ALL controls that you want to appear must have ShowMe in the Tag property.  I would test the Tag for a value that tells the code this is one of the show/hide buttons.  Perhaps:

 

For Each ctrl In Me.Detail.Controls

    If ctrl.Tag = "ButtonShowHide" Then

        ctrl.Visible = True

    End If

Next ctrl

 

The above code changes the visible property ONLY for controls that have that tag value.  You could use a similar technique in the code to re-hide the buttons.

 

John Viescas, Author

Microsoft Access 2010 Inside Out

Microsoft Access 2007 Inside Out

Microsoft Access 2003 Inside Out

Building Microsoft Access Applications

SQL Queries for Mere Mortals

http://www.viescas.com/

(Paris, France)

 

 

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Jim Wagner
Sent: Tuesday, November 05, 2013 4:31 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: Re: [MS_AccessPros] RE: Dim Variable question

 




Thank You Bill, But I also have a button that appears to allow me to hide the buttons. How could I use it to hide the buttons? I do not see any reference to visible = true or false 

 

Jim Wagner


 

On Tuesday, November 5, 2013 8:20 AM, "wrmosca@comcast.net" <wrmosca@comcast.net> wrote:

 

Jim

 

I usually use the .Tag property for grouping controls.The .Tag property is just a string that you can use as an identifier for lots of things. And using For Each loops lets you do it without knowing the count.

 

Dim ctrl As Control

 

For each ctrl in me.Detail.Controls

            Ctrl.Visible =  (ctrl.Tag = "ShowMe")

Next

 

You can even go one step further and use a delimiter and break the tag into an array.

'Here the tags are strings like "ShowMe|Delete" or "ShowMe|Update"

Dim ctrl As Control

Dim aryList As Variant

 

aryList = Split(ctrl.Tag, "|")

 

For each ctrl in me.Detail.Controls

            Ctrl.Visible =  (aryList(0) = "ShowMe")

            Ctrl.Caption = aryList(1)

Next

 

Regards,

Bill Mosca, Founder - MS_Access_Professionals

Microsoft Office Access MVP

My nothing-to-do-with-Access blog

 



---In MS_Access_Professionals@yahoogroups.com, <luvmymelody@yahoo.com> wrote:

Hello all,

 

I am struggling with a vba question.

 

I have a form that has multiple buttons that are hidden by default. With the click of a button the buttons are made visible. There are 21 of them. I have learned about For Next and declaring a variable, but I am trying to take it a step further. Currently I have the code to list every button name and the visible property to true when the user clicks the main button. But I see that listing every button name is a lot of typing. For aesthetics I have the button and a smaller button with an arrow on it next to it. The smaller buttons have a name of cmdArrowDelete1 down to 21. 

The code right now is below and it works great. But I would like to add the other buttons to the code. I have the names with names such as cmdDelete1Accounts and cmdDelete2Accruals. 

How can I add the buttons to the For next so they will appear like the other buttons?

 

Thank You 

Jim Wagner

 

Dim i As Integer

 

For i = 1 To 21

    Me("cmdArrowDelete" & i).Visible = True

    Next

 




__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (6)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar