By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,252 Members | 1,684 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,252 IT Pros & Developers. It's quick & easy.

Delete All Lines

P: n/a
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
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

Nov 13 '05 #2

P: n/a
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

Nov 13 '05 #3

P: n/a
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
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.