Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2009
    Posts
    85

    Unanswered: Clearing a form minus 1

    Hello, asking yet another question
    I use this code to clear a form, I have tried to alter it to exclude a control say MyTextbox from being cleared (I want it to have a default value) but have had no luck. Any help would be appreciated Thanks. Tim



    'Clear All TextBoxes and Set all Check boxes to false
    Dim ctl As Control
    For Each ctl In Me.Controls
    If ctl.ControlType = acTextBox Then
    ctl.Value = ""
    ElseIf ctl.ControlType = acCheckBox Then
    ctl.Value = False

    End If
    Next ctl
    Set ctl = Nothing

  2. #2
    Join Date
    Mar 2007
    Posts
    277
    Try:
    Code:
    'Clear All TextBoxes and Set all Check boxes to false
    Dim ctl As Control
    For Each ctl In Me.Controls
       If ctl.ControlType = acTextBox Then
          If ctl.Name <> "MyTextBox" Then
             ctl.Value = ""
          End If   ElseIf ctl.ControlType = acCheckBox Then
          ctl.Value = False
       End If
    Next ctl
    '-- YOU DO NOT NEED THIS NEXT LINE
    Set ctl = Nothing
    RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP, ac07, ac10 - WinXP Pro, Win7 Pro
    Please reply to this forum so all may learn.

  3. #3
    Join Date
    Apr 2009
    Posts
    85
    Thank's, this worked fine. I had tried something similar but did'nt get it quite right. Tim

  4. #4
    Join Date
    Mar 2007
    Posts
    277
    Glad I could help.
    RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP, ac07, ac10 - WinXP Pro, Win7 Pro
    Please reply to this forum so all may learn.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •