Djblois,
Here's the code revisions you need.
To check to see if the control exists before adding.
[VBA]
Private Sub CommandButton1_Click()
Dim c As Control, F As Boolean
rnm = "ReportName"
LBL = "ReportLabel"
F = False
For Each c In Me.Controls
If c.Name = rmn Then
F = True
End If
Next c
If F = False Then
Email.Controls.Add bstrProgId:="Forms.Label.1", Name:=rnm, Visible:=True
Email.Controls(rnm).Top = 70
Email.Controls(rnm).Left = 6
Email.Controls(rnm).Height = 30
Email.Controls(rnm).Width = 150
Email.Controls(rnm).Caption = "What do you want to name the file?"
Email.Controls(rnm).Font.Bold = True
Else
'Not sure what you want to do here
End If
End Sub
[/VBA]
To remove an existing control
[VBA]
Private Sub CommandButton2_Click()
Email.Controls.Remove "ReportName"
End Sub
[/VBA]
HTH
Cal




Reply With Quote