Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2004
    Location
    Edinburgh, Scotland
    Posts
    17

    Unanswered: Can't clear form

    I've got a form made of a mixture of text boxes and combo boxes. I have a clear button on the form, but I can't get it to work. Here's everything I've tried so far:

    1. clearDetails As CommandButton
    2. Me.Refresh
    3. Me.clearDetails
    4. cboMake= ""
    5. cboMake=NULL
    6. clearDetails As CommandButton
    7. .RowSource = "(All);" & .RowSourcecboMake.Value = Null

    What am I doing wrong?

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Lightbulb

    To clear a comboBox use
    Me.yourComboBox.RowSource=""


    To clear a TextBox use
    Me.yourTextBox=""

  3. #3
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by hammbakka
    To clear a comboBox use
    Me.yourComboBox.RowSource=""


    To clear a TextBox use
    Me.yourTextBox=""
    How's about : SomeComboBox.Value=""
    SomeTextBox.Value=""
    Back to Access ... ADO is not the way to go for speed ...

  4. #4
    Join Date
    Oct 2004
    Location
    Edinburgh, Scotland
    Posts
    17
    Neither of them worked. Even tried replacing "" with NULL but still no luck.

    Is there a way to clear an entire form with one part of code, rather than writing something for each combo or text box?

    Here what I've got in case it helps any:

    Private Sub Clear_Click()
    Me.cboMake.RowSource = ""
    Me.TxtBPhoneNo = ""

    On Error GoTo Err_Clear_Click

    DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70

    Exit_Clear_Click:
    Exit Sub

    Err_Clear_Click:
    MsgBox Err.Description
    Resume Exit_Clear_Click

    End Sub

  5. #5
    Join Date
    Apr 2004
    Location
    Kingsland, Georgia
    Posts
    231
    you can always try to use the following code:
    Code:
    Dim ctl As Control
            For Each ctl In Controls
                If TypeOf ctl Is TextBox Then
                    ctl.Value = ""
                End If
                If TypeOf ctl Is ComboBox Then
                    ctl.Value = Null
                End If
            Next
    That should cycle through all the controls on your form, and if they are a textbox or combobox, it'll clear the values out. good luck.
    Last edited by jmahaffie; 10-14-04 at 10:42. Reason: Added more info

  6. #6
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Quote Originally Posted by M Owen
    How's about : SomeComboBox.Value=""
    SomeTextBox.Value=""
    Owen,
    The value property needs the focus, doesn't it

  7. #7
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by hammbakka
    Owen,
    The value property needs the focus, doesn't it
    Not at all Hammy ... The .Text property does ... Something else to remember is that .Value DOES NOT trigger any events - BeforeUpdate, AfterUpdate, Change, etc ...
    Back to Access ... ADO is not the way to go for speed ...

  8. #8
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Thanks for the info...

Posting Permissions

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