S
scott
On a continuous form that sorts columns when user clicks the column headers.
I also have some embedded gif icons next to each column header caption that
display ascending and descending order and named them with the convention of
icon_up_TheControlName and icon_down_TheControlName. I also have an embedded
gif icon called "cmdRemove" on the form.
If I run my sub in the "USAGE" section below, my sub FlipSortImages iterates
through the form and correctly changes the icon_up_firstName control visible
property to true and sets all of the other control's visible property to
false. The problem is that I can't seem to exclude the "cmdRemove" icon from
being affected.
In my code I have a simple message box that should fire when the sub reaches
the "cmdRemove" icon, but it won't recognize it. Can someone setup a simple
test form with a few controls using my naming convention and help me find a
conditional test that will exclude any image controls that have the
"cmdRemove" name or for that matter, any image control name that begins with
"cmd"?
I also tried using the InStr() function to no avail.
'USAGE *******************
Call FlipSortImages(Me.icon_up_firstName)
'EXAMPLE IMAGE CONTROL NAMES *******************
icon_up_firstName
icon_down_firstName
icon_up_lastName
icon_down_lastName
cmdRemove
'CODE ************************************
Sub FlipSortImages(ctlImageHot As Control)
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acImage Then
If InStr(ctlImageHot.Name, "icon_up_") > 0 Or
InStr(ctlImageHot.Name, "icon_down_") > 0 Then
If ctl.Name <> ctlImageHot.Name Then
If ctl.Name = "cmdRemove" Then ' this is the part
MsgBox ctl.Name
Else
ctl.Visible = False
End If
Else
ctl.Visible = True
End If
End If
End If
Next ctl
End Sub
I also have some embedded gif icons next to each column header caption that
display ascending and descending order and named them with the convention of
icon_up_TheControlName and icon_down_TheControlName. I also have an embedded
gif icon called "cmdRemove" on the form.
If I run my sub in the "USAGE" section below, my sub FlipSortImages iterates
through the form and correctly changes the icon_up_firstName control visible
property to true and sets all of the other control's visible property to
false. The problem is that I can't seem to exclude the "cmdRemove" icon from
being affected.
In my code I have a simple message box that should fire when the sub reaches
the "cmdRemove" icon, but it won't recognize it. Can someone setup a simple
test form with a few controls using my naming convention and help me find a
conditional test that will exclude any image controls that have the
"cmdRemove" name or for that matter, any image control name that begins with
"cmd"?
I also tried using the InStr() function to no avail.
'USAGE *******************
Call FlipSortImages(Me.icon_up_firstName)
'EXAMPLE IMAGE CONTROL NAMES *******************
icon_up_firstName
icon_down_firstName
icon_up_lastName
icon_down_lastName
cmdRemove
'CODE ************************************
Sub FlipSortImages(ctlImageHot As Control)
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acImage Then
If InStr(ctlImageHot.Name, "icon_up_") > 0 Or
InStr(ctlImageHot.Name, "icon_down_") > 0 Then
If ctl.Name <> ctlImageHot.Name Then
If ctl.Name = "cmdRemove" Then ' this is the part
MsgBox ctl.Name
Else
ctl.Visible = False
End If
Else
ctl.Visible = True
End If
End If
End If
Next ctl
End Sub