toggling visibility of labels through code

  • Thread starter Thread starter DawnTreader
  • Start date Start date
D

DawnTreader

Hello All

i need a little help trying to get this to work

i have 3 sets of lables for 3 different languages for my fields. i am trying
to use a variable stored in a combo box on a floating always open form to
determine which language label should show. what is wrong with this code?

Private Sub frmLanguage()
Dim ctl As Control
Dim frmUserLanguage As String
Dim lblLanguage As String

frmUserLanguage = Forms!frmMainMenu.Form!cboEmployee.Column(18)

MsgBox frmUserLanguage

For Each ctl In Me.Controls
If ctl.ControlType = acLabel Then
lblLanguage = ctl.Tag
MsgBox lblLanguage
Select Case lblLanguage
Case lblLanguage = frmUserLanguage
ctl.Visible = True
Case lblLanguage = "Always"
ctl.Visible = True
Case Else
ctl.Visible = False
End Select
End If
Next
End Sub
 
doh!

figured it out, thanks any ways.

Private Sub frmLanguage()
Dim ctl As Control
Dim frmUserLanguage As String
Dim lblLanguage As String

frmUserLanguage = Forms!frmMainMenu!cboEmployee.Column(18)

For Each ctl In Me.Controls
If ctl.ControlType = acLabel Then
lblLanguage = ctl.Tag
Select Case lblLanguage
Case frmUserLanguage
ctl.Visible = True
Case "Always"
ctl.Visible = True
Case Else
ctl.Visible = False
End Select
End If
Next
End Sub
 
Yes, that's what Marsh is saying

For Each ctl In Me.Controls
If ctl.ControlType = acLabel Then
lblLanguage = ctl.Tag
MsgBox lblLanguage

ctl.Visible = ((lblLanguage = frmUserLanguage) _
Or (lblLanguage = "Always"))
End If
Next ctl
 
Back
Top