Managing Visible Property of Label Control

A

Alan

Good Morning!

I've been scratching my head on this one and could use a hand... I am trying
to cycle through unassociated label controls that I have added to illuminate
a "highlight" next to a column of navigation links. All of the labels have
visibility OFF before the code runs, and are named "HILITE01" thru "HILITE13"
.. The TAG property for all is set to "HILITE" for group identification. The
code runs without errors but does not successfully turn ON visibility for the
appropriate control whose last two name digits match the "intFolderNo"
variable...
-------------------------------------------------------------------
Private Sub Form_Current()
Dim ctl As Control, strX As String, intFolderNo as Integer
intFolderNo = Me.OpenArgs
Me.FormTitle = DLookup("[Folder]", "tbl_SYS-DMSNAV", "FolderOrder=" &
intFolderNo)
strX = Format(intFolderNo, "00")
For Each ctl In Forms![frm_DMSNAV].Controls
If ctl.Tag = "HILITE" Then
If Right(ctl.Name, 2) = strX Then
ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl
Set ctl = Nothing
Me.btnClose.SetFocus
End Sub
 
G

GeoffG

1. I think you need to declare a string variable in the
General Declarations section and use the Form_Open event to
store the OpenArgs value in the string variable. If you
don't capture OpenArgs in the Open event, I think the value
is lost by the time the current event runs. (But you might
want to check this using Debug.Print and viewing the
Immediate window.)

2. The OpenArgs value will be set once when the form
opens, but the Form's Current event will fire each time the
record changes in the form. I assume you have a reason for
wanting to apply the same OpenArgs value to all records.


Geoff
 
A

Alan

Thanks, Geoff... I did make the variable declaration a general one to catch
the OpenArgs value at form OPEN, rather than later when the CURRENT event
fired. It seems that the problem was when I set the control TAG properties
however... I had incorrectly set the TAG property on each control WITH
quotation marks, so that the value never matched when the IF...THEN was
evaluated. I appreciate your willingness to help. Removing the quotes from
the TAG value in the PROPERTIES window solved the problem...

Alan


GeoffG said:
1. I think you need to declare a string variable in the
General Declarations section and use the Form_Open event to
store the OpenArgs value in the string variable. If you
don't capture OpenArgs in the Open event, I think the value
is lost by the time the current event runs. (But you might
want to check this using Debug.Print and viewing the
Immediate window.)

2. The OpenArgs value will be set once when the form
opens, but the Form's Current event will fire each time the
record changes in the form. I assume you have a reason for
wanting to apply the same OpenArgs value to all records.


Geoff




Alan said:
Good Morning!

I've been scratching my head on this one and could use a
hand... I am trying
to cycle through unassociated label controls that I have
added to illuminate
a "highlight" next to a column of navigation links. All of
the labels have
visibility OFF before the code runs, and are named
"HILITE01" thru "HILITE13"
. The TAG property for all is set to "HILITE" for group
identification. The
code runs without errors but does not successfully turn ON
visibility for the
appropriate control whose last two name digits match the
"intFolderNo"
variable...
-------------------------------------------------------------------
Private Sub Form_Current()
Dim ctl As Control, strX As String, intFolderNo as
Integer
intFolderNo = Me.OpenArgs
Me.FormTitle = DLookup("[Folder]", "tbl_SYS-DMSNAV",
"FolderOrder=" &
intFolderNo)
strX = Format(intFolderNo, "00")
For Each ctl In Forms![frm_DMSNAV].Controls
If ctl.Tag = "HILITE" Then
If Right(ctl.Name, 2) = strX Then
ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl
Set ctl = Nothing
Me.btnClose.SetFocus
End Sub
 
G

GeoffG

Alan: Glad it's solved.

Geoff



Alan said:
Thanks, Geoff... I did make the variable declaration a
general one to catch
the OpenArgs value at form OPEN, rather than later when
the CURRENT event
fired. It seems that the problem was when I set the
control TAG properties
however... I had incorrectly set the TAG property on each
control WITH
quotation marks, so that the value never matched when the
IF...THEN was
evaluated. I appreciate your willingness to help. Removing
the quotes from
the TAG value in the PROPERTIES window solved the
problem...

Alan


GeoffG said:
1. I think you need to declare a string variable in
the
General Declarations section and use the Form_Open event
to
store the OpenArgs value in the string variable. If you
don't capture OpenArgs in the Open event, I think the
value
is lost by the time the current event runs. (But you
might
want to check this using Debug.Print and viewing the
Immediate window.)

2. The OpenArgs value will be set once when the form
opens, but the Form's Current event will fire each time
the
record changes in the form. I assume you have a reason
for
wanting to apply the same OpenArgs value to all records.


Geoff




Alan said:
Good Morning!

I've been scratching my head on this one and could use
a
hand... I am trying
to cycle through unassociated label controls that I
have
added to illuminate
a "highlight" next to a column of navigation links. All
of
the labels have
visibility OFF before the code runs, and are named
"HILITE01" thru "HILITE13"
. The TAG property for all is set to "HILITE" for group
identification. The
code runs without errors but does not successfully turn
ON
visibility for the
appropriate control whose last two name digits match
the
"intFolderNo"
variable...
-------------------------------------------------------------------
Private Sub Form_Current()
Dim ctl As Control, strX As String, intFolderNo as
Integer
intFolderNo = Me.OpenArgs
Me.FormTitle = DLookup("[Folder]", "tbl_SYS-DMSNAV",
"FolderOrder=" &
intFolderNo)
strX = Format(intFolderNo, "00")
For Each ctl In Forms![frm_DMSNAV].Controls
If ctl.Tag = "HILITE" Then
If Right(ctl.Name, 2) = strX Then
ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl
Set ctl = Nothing
Me.btnClose.SetFocus
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top