Selasa, 05 November 2013

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
http://www.thatlldoit.com
Microsoft Office Access MVP
https://mvp.support.microsoft.com/profile=C4D9F5E7-BB03-4291-B816-64270730881E
My nothing-to-do-with-Access blog
http://wrmosca.wordpress.com



---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 (5)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar