A
alex
Assign string to control
Hello,
Using Access ‘03
I’m attempting to convert a string name to a control name…Here’s the
code:
Private Sub Form_Current()
Dim ctl As Control
For Each ctl In Me.Controls
If Not TypeOf ctl Is Label Then 'omit labels
If IsNull(ctl) Then 'if no value
Dim strLabel As String
strLabel = "Me.lbl" & (ctl.Name)
strLabel.Visible = True ‘does not work!
'Debug.Print (strLabel)
Else
End If
End If
Next ctl
End Sub
All of my labels have an “lbl” prefix. If the ctl is null, I’d like
to concatenate the “lbl” in front of (ctl.name) and hide the label.
It seems to work (at least the name) in the immediate window.
I can’t get Access to recognize the control, however.
Keep in mind that my labels are NOT linked to my textboxes et al. I
did this because I place the label on top of the textbox to save
space. If the textbox is empty, the label is displayed. If not, the
textbox value appears. This only seems to work when the label and
texbox are not linked.
Thanks,
alex
Hello,
Using Access ‘03
I’m attempting to convert a string name to a control name…Here’s the
code:
Private Sub Form_Current()
Dim ctl As Control
For Each ctl In Me.Controls
If Not TypeOf ctl Is Label Then 'omit labels
If IsNull(ctl) Then 'if no value
Dim strLabel As String
strLabel = "Me.lbl" & (ctl.Name)
strLabel.Visible = True ‘does not work!
'Debug.Print (strLabel)
Else
End If
End If
Next ctl
End Sub
All of my labels have an “lbl” prefix. If the ctl is null, I’d like
to concatenate the “lbl” in front of (ctl.name) and hide the label.
It seems to work (at least the name) in the immediate window.
I can’t get Access to recognize the control, however.
Keep in mind that my labels are NOT linked to my textboxes et al. I
did this because I place the label on top of the textbox to save
space. If the textbox is empty, the label is displayed. If not, the
textbox value appears. This only seems to work when the label and
texbox are not linked.
Thanks,
alex