toggling visibility of labels through code

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
 
D

DawnTreader

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
 
D

Douglas J. Steele

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
 

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