Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Thanked 0 Times in 0 Posts

    Clearing fields (Access 2000)

    I have a search form in my db. The form has text boxes the users type in to search for specific data in the db.. Example one text box is called txtState or txtCity etc. My question is how can I create a button on the form that will clear all the data the user typed in if they want to try a new search. So when the button is pressed the text boxes will contain no data. The text boxes and form are unbound if that helps. Thanks..

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Clearing fields (Access 2000)

    If you want to clear *all* text boxes, you can do it like this (cmdClear is the fictitious name of the command button):

    Private Sub cmdClear_Click()
    Dim ctl As Control
    For Each ctrl In Me.Controls
    If ctl.ControlType = acTextBox Then
    ctl = Null
    End If
    Next ctl
    Set ctl = Nothing
    End Sub

    If you want to clear only specified text boxes, you'll have to enumerate them, unless you can distinguish them by their name or by a special property.

Posting Permissions

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