Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

hide tab control based on value of several controls

1 view
Skip to first unread message

Kurt

unread,
Mar 10, 2011, 3:45:42 PM3/10/11
to
I have 10 combo boxes with a tag property of "check".

If any of these 10 combo boxes Is Null, I would like to hide a tab
control on the form.

With the function I wrote for this, the tab control stays visible
regardless. Also, every time the code fires, the tab control flickers
for about 10 seconds.

This is what I have:

Private Sub ShowHideTab()
Dim Ctl As Control
On Error Resume Next

If Ctl.Tag = "start" Then
For Each Ctl In Me.Controls
If Ctl.Value = Null Then
Me.TabCtl166.Visible = False
Else
Me.TabCtl166.Visible = True
End If
Next Ctl
End If

Any suggestions?

Ken Snell

unread,
Mar 11, 2011, 9:33:17 PM3/11/11
to
May I suggest this as an alternative? NOTE: I'm writing this using your
generic approach instead of using hard-coded names for the combo box
controls (note: using hard-coded names will make the code run much faster).

Private Sub ShowHideTab()
Dim Ctl As Control

Dim intValue As Int

intValue = 1

For Each Ctl In Me.Controls

If Ctl.ControlType = acComboBox And Ctl.Tag = "start" And _
Ctl.Value Is Null Then intValue = 0
Next Ctl

Me.TabCtl166.Visible = intValue
End Sub

--

Ken Snell
http://www.accessmvp.com/KDSnell/


"Kurt" <heisl...@gmail.com> wrote in message
news:f54d6f73-09d5-4d0f...@j35g2000prb.googlegroups.com...

Kurt

unread,
Mar 13, 2011, 5:14:03 PM3/13/11
to
Ken - I like your approach. Very compact!

However, when the routine is called (either from the OnCurrent event
or from an AfterUpdate event of one of the combo boxes) I get this
error:

"Object doesn't support this property or method."

Debug points to the If Ctl.ControlType ... line.

Any ideas?


On Mar 11, 10:33 pm, "Ken Snell" <kthsneisll...@ncoomcastt.renaetl>
wrote:


> May I suggest this as an alternative? NOTE: I'm writing this using your
> generic approach instead of using hard-coded names for the combo box
> controls (note: using hard-coded names will make the code run much faster).
>
> Private Sub ShowHideTab()
> Dim Ctl As Control
> Dim intValue As Int
>
> intValue = 1
>
> For Each Ctl In Me.Controls
>      If Ctl.ControlType = acComboBox And Ctl.Tag = "start" And _
>         Ctl.Value Is Null Then intValue = 0
> Next Ctl
>
> Me.TabCtl166.Visible = intValue
> End Sub
>
> --
>
>         Ken Snellhttp://www.accessmvp.com/KDSnell/
>

> "Kurt" <heislerk...@gmail.com> wrote in message

Ken Snell

unread,
Mar 14, 2011, 10:21:25 PM3/14/11
to
Ah, sorry. Got too compact; not all controls have a .Value property. Try
this:

Private Sub ShowHideTab()
Dim Ctl As Control
Dim intValue As Int

intValue = 1

For Each Ctl In Me.Controls

If Ctl.ControlType = acComboBox And Ctl.Tag = "start" Then
If Ctl.Value Is Null Then intValue = 0
End If
Next Ctl

Me.TabCtl166.Visible = intValue
End Sub

--

Ken Snell
http://www.accessmvp.com/KDSnell/


"Kurt" <heisl...@gmail.com> wrote in message

news:1f18ca0d-b158-4ad4...@a11g2000pri.googlegroups.com...

Ken Snell

unread,
Mar 14, 2011, 10:42:44 PM3/14/11
to
And, to avoid some unnecessary looping:

Private Sub ShowHideTab()
Dim Ctl As Control
Dim intValue As Int

intValue = 1

For Each Ctl In Me.Controls
If Ctl.ControlType = acComboBox And Ctl.Tag = "start" Then
If Ctl.Value Is Null Then intValue = 0
End If

If intValue = 0 Then Exit For
Next Ctl

Me.TabCtl166.Visible = intValue
End Sub

--

Ken Snell
http://www.accessmvp.com/KDSnell/

"Ken Snell" <kthsne...@ncoomcastt.renaetl> wrote in message
news:ilmif5$l9p$1...@speranza.aioe.org...

0 new messages