Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / December 2007

Tip: Looking for answers? Try searching our database.

Bound many controls to a "frame" in a form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rahmad - 02 Dec 2007 07:09 GMT
Hi all,
I use and option group to shown or hide many controls
in my form ( text boxes,labels,and a combo box).Is there
a way to bound these controls to a ( called frame ) so that
when we write the code, we just need to type this " frame "
name not alot of these controls name.Is it possible

Thank's
Douglas J. Steele - 02 Dec 2007 13:45 GMT
Not that I'm aware of.

A common technique is to set the Tag property of the controls so that the
ones you want to control all have the same value there (say "xyz"), and then
write a routine along the lines of:

Sub ToggleVisibility(VisibilityStatus As Boolean)
Dim ctlCurr As Control

' Since you can't hide a control that has focus,
' you need to ensure that focus is set to a control
' that will always be visible before running the loop.

 Me.SomeControl.SetFocus

 For Each ctlCurr In Me.Controls
   If ctlCurr.Tag = "xyz" Then
     ctlCurr.Visible = VisibilityStatus
   End If
 Next ctlCurr

End Sub

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> Hi all,
> I use and option group to shown or hide many controls
[quoted text clipped - 4 lines]
>
> Thank's
rahmad - 03 Dec 2007 01:13 GMT
I'm sorry Doug,
What do you mean by
> the ones you want to control all have the same value there (say "xyz")
I'm not fully understand.

Thank's

> Not that I'm aware of.
>
[quoted text clipped - 32 lines]
> >
> > Thank's
Douglas J. Steele - 03 Dec 2007 13:08 GMT
The Tag property is free-form text: you can put whatever you want in it. All
I'm saying is put some unique expression into the property (I used "xyz" as
my example), and then for each control, check whether its Tag property is
set to that value.

You may also be interested in reading my June, 2004 "Access Answers" column
in Pinnacle Publication's "Smart Access". You can download the column (and
sample database) for free at
http://www.accessmvp.com/djsteele/smartaccess.html

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> I'm sorry Doug,
> What do you mean by
[quoted text clipped - 40 lines]
>> >
>> > Thank's
New_Access - 04 Dec 2007 01:16 GMT
It sound rationally.
But where do I have to put that 'magic word' ( code )

> The Tag property is free-form text: you can put whatever you want in it. All
> I'm saying is put some unique expression into the property (I used "xyz" as
[quoted text clipped - 55 lines]
> >> >
> >> > Thank's
Douglas J. Steele - 04 Dec 2007 12:15 GMT
Select all of the relevant controls at once (you can "lasso" them, you can
click on each one while holding down the Shift key, or there are other means
of selecting multiple controls at once: just make sure you've only selected
the ones of interest).

Once you've got them all selected, look at the Properties window. Whatever
you type there will apply to all of the selected controls. (That's why the
list of properties is so much shorter). Find the Tag property, and type your
magic word there.

Alternatively, you can select each control one at a time and type the word
into the Properties window for each one.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> It sound rationally.
> But where do I have to put that 'magic word' ( code )
[quoted text clipped - 64 lines]
>> >> >
>> >> > Thank's
New_Access - 05 Dec 2007 01:57 GMT
Sorry Doug,
In what even I have to write the below routine you had
mentioned in your previous post.

Sub ToggleVisibility(VisibilityStatus As Boolean)
Dim ctlCurr As Control

' Since you can't hide a control that has focus,
' you need to ensure that focus is set to a control
' that will always be visible before running the loop.

 Me.SomeControl.SetFocus

 For Each ctlCurr In Me.Controls
   If ctlCurr.Tag = "xyz" Then
     ctlCurr.Visible = VisibilityStatus
   End If
 Next ctlCurr

End Sub

Thank's

> Select all of the relevant controls at once (you can "lasso" them, you can
> click on each one while holding down the Shift key, or there are other means
[quoted text clipped - 82 lines]
> >> >> >
> >> >> > Thank's
Douglas J. Steele - 05 Dec 2007 02:15 GMT
That routine can be called from wherever you want. Your original question
was how to avoid having to write a number of statements to make a group of
controls visible or not. What event were you planning on using?

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> Sorry Doug,
> In what even I have to write the below routine you had
[quoted text clipped - 117 lines]
>> >> >> >
>> >> >> > Thank's
New_Access - 05 Dec 2007 05:14 GMT
I want the controls visible when otion group value is 2.
Is it good idea if I put it in 'on click' event of the option group
or 'after update',cause the form just for adding new records only,
so when the from open the option group value perhaps always 1.
Thank's

> That routine can be called from wherever you want. Your original question
> was how to avoid having to write a number of statements to make a group of
[quoted text clipped - 39 lines]
> >> Whatever
> >> you type there will apply to all of the selected controls. (That's why

> >> the
> >> list of properties is so much shorter). Find the Tag property, and type
[quoted text clipped - 83 lines]
> >> >> >> >
> >> >> >> > Thank's
Douglas J. Steele - 05 Dec 2007 13:04 GMT
Either should work.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

>I want the controls visible when otion group value is 2.
> Is it good idea if I put it in 'on click' event of the option group
[quoted text clipped - 140 lines]
>> >> >> >> >
>> >> >> >> > Thank's
New_Access - 06 Dec 2007 09:53 GMT
I'm sorry Doug,
I can't make it work with this.

Private Sub SpeedMode_opt_AfterUpdate()

'This code for hide or shown
'fields of speed step 2 specification

On Error GoTo SpeedMode_opt_AfterUpdate

Dim ctlCurr As Control
Dim booVisibility As Boolean
Dim strControlToToggle As String
Dim strCurrControlName As String

'If speed mode option is 1,speed step 2 specification fields
'is invisible.If option is, all spec fields of speed step 2
'is visible

   booVisibility = Not Me.SpeedMode_opt
   strControlsToToggle = ListFormControls(Me.Name, "xyz")

   If Len(strControlsToToggle) > 1 Then
       For Each ctlCurr In Me.Controls
           strCurrControlName = ";" & ctlCurr.Name & ";"
           If InStr(1, strControlsToToggle, strCurrControlName,
vbTextCompare) > 1 Then
           ctlCurr.Visible = booVisibility
       End If

End_SpeedMode_opt_AfterUpdate:
   Exit Sub

Err_SpeedMode_opt_AfterUpdate:
   MsgBox Err.Description & "(" & Err.Number & ") in " & _
   Me.Name & ".SpeedMode_opt_AfterUpdate", _
   vbOKOnly + vbCritical, "Error Occured"
Resume End_SpeedMode_opt_AfterUpdate

End Sub

> Either should work.
>
[quoted text clipped - 147 lines]
> >> >> >> >> >
> >> >> >> >> > Thank's
Douglas J. Steele - 07 Dec 2007 13:33 GMT
That bears little resemblance to the code I suggested.

What's the function ListFormControls(Me.Name, "xyz")? What does it return?

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> I'm sorry Doug,
> I can't make it work with this.
[quoted text clipped - 201 lines]
>> >> >> >> >> >
>> >> >> >> >> > Thank's
New_Access - 08 Dec 2007 01:09 GMT
Compile Error:
Sub or function not defined

> That bears little resemblance to the code I suggested.
>
[quoted text clipped - 210 lines]
> >> >> >> >> >> >
> >> >> >> >> >> > Thank's
Douglas J. Steele - 08 Dec 2007 12:59 GMT
Afraid I can't help you, since I never suggested a function by that name in
my solution so I have no idea what it's supposed to be,

Just to reiterate, my suggestion was:

Sub ToggleVisibility(VisibilityStatus As Boolean)
Dim ctlCurr As Control

' Since you can't hide a control that has focus,
' you need to ensure that focus is set to a control
' that will always be visible before running the loop.

 Me.SomeControl.SetFocus

 For Each ctlCurr In Me.Controls
   If ctlCurr.Tag = "xyz" Then
     ctlCurr.Visible = VisibilityStatus
   End If
 Next ctlCurr

End Sub

To have your AfterUpdate event change the visibility, you'd use

Private Sub SpeedMode_opt_AfterUpdate()
'This code for hide or shown
'fields of speed step 2 specification

On Error GoTo SpeedMode_opt_AfterUpdate

Dim booVisibility As Boolean

 booVisibility = Not Me.SpeedMode_opt
 Call ToggleVisibility(booVisibility)

End_SpeedMode_opt_AfterUpdate:
 Exit Sub

Err_SpeedMode_opt_AfterUpdate:
 MsgBox Err.Description & "(" & Err.Number & ") in " & _
   Me.Name & ".SpeedMode_opt_AfterUpdate", _
   vbOKOnly + vbCritical, "Error Occured"
 Resume End_SpeedMode_opt_AfterUpdate

End Sub

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> Compile Error:
> Sub or function not defined
[quoted text clipped - 231 lines]
>> >> >> >> >> >> >
>> >> >> >> >> >> > Thank's
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.