Rolf wrote:
Thanks for your quick response!
I would like to delete the lines; not make them invisible. Is there a way?
Rolf
"Salad" <oi*@vinegar.com> wrote in message
news:rI*****************@newsread1.news.pas.earthl ink.net...
Rolf wrote:
I have a form with about 15 to 20 lines. Their names are LineXXX. What
code
can I put in the click event of a button to delete all the lines?
Thanks!
Rolf
On error resume next
For i = 1 to 20
l = "Line" & i
Me("Line" & i).Visible = False
Next i
Can you open the form in design mode, click on the offending lines, and
press the Delete key? Even if you use code, you'll have to open them up
in design view to delete.
Here's some code. It won't delete all for the controls...the For/Each
is interrupted by the deletion of controls...but enough get deleted to
put you on track. Copy a form with lots of controls and run this code.
Then open the form in design mode and check it out.
Sub DeleteControlsOnForm()
Dim ctl As Control
Dim frm As Form
DoCmd.OpenForm "Test", acDesign, , , , acHidden
Set frm = Forms!test
For Each ctl In frm.Controls
'optional debug statement
Debug.Print ctl.Name
DeleteControl frm.Name, ctl.Name
Next ctl
Set ctl = Nothing
Set frm = Nothing
DoCmd.Close acForm, "test", acSaveYes
MsgBox "Done"
End Sub