Results 1 to 6 of 6
  1. #1
    bbarrene is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    9

    How to Reset Comboboxes

    Hello,



    I found a tutorial on how to use combo boxes to filter. I got it to work but I cannot reset the succeeding boxes when i change the initial combo box to another selection.

    In the first picture below, everything flows smoothly as far as filtering but when I change the location to Madison, the Equipment and Station choices dont clear like the Plant does.

    Can anyone help me with the coding to reset the succeeding boxes of combo box when a change a selection of a combobox that precedes them.

    Thanks

    Coding Used:
    Option Compare Database

    Private Sub cboLocation_AfterUpdate()
    Dim sPlantSource As String

    sPlantSource = "Select [tblPlant].[lngPlantID], [tblPlant].[lngLocationID], [tblPlant].[strPlantName] " & _
    "FROM tblPlant " & _
    "WHERE [lngLocationID] = " & Me.cboLocation.Value
    Me.cboPlant.RowSource = sPlantSource
    Me.cboPlant.Requery


    End Sub


    Private Sub cboPlant_AfterUpdate()

    Dim sEquipmentSource As String

    sEquipmentSource = "Select [tblEquipment].[lngEquipmentID], [tblEquipment].[lngPlantID], [tblEquipment].[strEquipmentName] " & _
    "FROM tblEquipment " & _
    "WHERE [lngPlantID] = " & Me.cboPlant.Value
    Me.cboEquipment.RowSource = sEquipmentSource
    Me.cboEquipment.Requery

    End Sub

    Private Sub cboEquipment_AfterUpdate()

    Dim sStationSource As String

    sStationSource = "Select [tblStation].[lngStationID], [tblStation].[lngEquipmentID], [tblStation].[strStationName] " & _
    "FROM tblStation " & _
    "WHERE [lngEquipmentID] = " & Me.cboEquipment.Value
    Me.cboStation.RowSource = sStationSource
    Me.cboStation.Requery

    End Sub

  2. #2
    llkhoutx is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Location
    Houston, Texas USA
    Posts
    373
    On the AftrerUpdate event of the first cbo, set each of the other cbos to Null.

  3. #3
    bbarrene is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    9
    I did that and the boxes become blank but when I drop down the combo box, the options are still available to pick. Does anyone know how I can reset the combo box to clear all of the choices similar to when it is first ran where there are no choices to choose from until you pick from the preceding combo box.

  4. #4
    llkhoutx is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Location
    Houston, Texas USA
    Posts
    373
    You have to reset the "row source" property of each of the combo boxes. I believer that you probably need to requery the other cbos on the after update event of the 1st cbo - if the 1st cbo is a filter for the other cbos.

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I often will Requery the ComboBox in either the GotFocus or OnEnter events of the cbo in situations like this.

  6. #6
    bbarrene is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    9
    I have already tried adding "Me.cboEquipment.Requery" and "Me.cboStation.Requery" under the Private Sub cboLocation_AfterUpdate() section but still no success.

    Man, this is stuff is harder than I thought it would be.

    Thank you guys for trying to help me out.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Unable to retrieve data on Comboboxes
    By ditogui in forum Forms
    Replies: 8
    Last Post: 12-29-2009, 10:26 AM
  2. Cascaded comboboxes in a form
    By luca in forum Forms
    Replies: 2
    Last Post: 11-22-2009, 05:36 AM
  3. subform comboboxes/Textboxes
    By terryvanduzee in forum Forms
    Replies: 2
    Last Post: 11-19-2009, 07:41 PM
  4. Refreshing comboboxes in a subform
    By KB_Dev in forum Programming
    Replies: 1
    Last Post: 04-07-2009, 12:12 PM
  5. reset primary key
    By emilylu3 in forum Access
    Replies: 1
    Last Post: 12-09-2005, 03:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums