Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2007 show/hide multiple controls. Panel or Frame? 2

Status
Not open for further replies.

pbelt

Programmer
Nov 5, 2006
2
0
0
GB

hi,

working on access 2007 and it's been a while since I did any form work, but wasn't there a panel or frame control that allowed you to group a number of controls so you could easily hide/show/move them?

At the moment I have them on a sub-form but surely there's a more suitable way?

ta
 
I don't think there is... In VB.Net you can.

Pampers [afro]
Keeping it simple can be complicated
 
Try using the TAG property of the controls; Then use something like
for each ctl in me.controls
If ctl.tag="blah" then
ctl.visible=false
end if

________________________________________________________
Zameer Abdulla
Help to find Missing people
 

Here's a step-by-step: Goto the form Design View, select all controls you want to group (hold down <Shift> and click on each in turn.) Goto Properties - Other and in the Tag Property enter "Group1" (without the quotation marks.) You can use any other tag you wish, of course.

Then in an appropriate event, use the following code:

Code:
Dim ctrl As Control
         
 For Each crtl In Me.Controls
  If ctrl.Tag = "Group1" Then ctrl.Visible = False
 Next

The great thing is that you can use different tags to manipulate different groups.


The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
That is a nice way to it...

Pampers [afro]
Keeping it simple can be complicated
 
It's a great way to loop specific controls, especially if there's a great deal of them! I've used it for a number of things, including doing validation on the form level.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Yep, validation, showing/hiding, locking, greyin out, disable/enable. Sure gonna try it. Tnx missinglinq.

Pampers [afro]
Keeping it simple can be complicated
 
Tried the tag-thing today. Beautiful!

Pampers [afro]
Keeping it simple can be complicated
 
I use the same for showing and hiding controls, ideal you use it aloung with a Like "*" statement then if you wish to ide the controls for defferent levels of access for diferent user groups the you can but using the like lets you use the tag for other things too

code shown below



For Each CTL In Me.Controls
If CTL.Tag Like "*" & "Group1" & "*" Then
CTL.Visible = True
End If

Next CTL




 
Yep, exactly. Tnx CLydeData for sharing. THis makes it a nice day already ;-)

Pampers [afro]
Keeping it simple can be complicated
 
There are loads of uses for it.

if you have an invoice system then certain fields/subforms can have Locked and enabled properties turned on and off as required to prevent changes to the invoice value after it has been sent.

If some staff are not permited to see invoice/financiel stuff the these fields/subforms can be hidden when they are logged in


Cheers

Jimmy

 
Hi ClydeDate,
Yes it is great for user management. Like on a main menu as I did yesterday, some controls are hidden, if a certain usergroup is logged on.... Instead defining all the controls for every usergroup.

Pampers [afro]
Keeping it simple can be complicated
 
I also use it on abound form where the fields have the same name as the data source

On open have all fields unbound then on a listbox or combo box afterupdate event selecting of record the ControlSource of text boxes etc can be set to the same as thier name

IE if you have an unbound text box Surname after the update event on your combo selection sets ControlSource=Surname same as name

This saves the user opening the form to the same record all the time it appears as a blank record with unbound controls


Dim CTL As Control
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ContactID] = " & Str(Me![QuickSearch])
Me.Bookmark = rs.Bookmark

For Each CTL In Me.Controls
If CTL.Tag Like "*" &"AddData" & "*" Then
CTL.ControlSource = CTL.Name
End If
Next CTL

 
Great!
I was looking for something like that for a while. Open a form in an unbound fashion and then bind the data in a couple of lines of code. Much appreciated ClydeData. Should this become a FAQ-topic (or is it already in)? Anyway, a big star for you.

Pampers [afro]
Keeping it simple can be complicated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top