Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2005
    Posts
    333

    Unanswered: Reset Combo Boxes

    I have a form with multiple combo boxes that are used to build a query. I want to have a reset button that will set the valule of every combo box to Null. I could do this :

    me.combo1.value = Null
    me.combo2.value = Null
    etc

    This becomes very combersome if I want to add/delete combo boxes. This should be possible using a for loop but I can't figure it out. Any suggestions? This was my last attempt that did not work.

    For i = 1 To Me.Controls.Count
    temp = "Item " & i
    Me.Controls.temp.Value = Null
    Next i

  2. #2
    Join Date
    Nov 2003
    Location
    LONDON
    Posts
    238
    You would use code like this:
    Dim ctl As Access.Control

    For Each ctl In Me.Controls
    If ctl.ControlType = acComboBox Then ctl.Value = "Hello combo"
    Next ctl

    Set ctl = Nothing
    Justin

  3. #3
    Join Date
    Jan 2004
    Location
    Aberdeen, Scotland
    Posts
    1,067
    how about this

    Code:
    Private Sub cmdReset_Click()
        Dim ctrl As Control
        
        For Each ctrl In Me.Controls
            If TypeOf ctrl Is ComboBox Then
                ctrl.Value = Null
            End If
        Next ctrl
            
    End Sub
    ----------------------
    edit
    sorry justin these are just about identical

  4. #4
    Join Date
    Feb 2005
    Posts
    333
    Wow that was quick and easy. Both responses work fine. Thanks

Posting Permissions

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