Results 1 to 2 of 2
  1. #1
    dccjr's Avatar
    dccjr is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Colorado Springs, CO
    Posts
    138

    Combo Box Won't Fill

    I have several combo boxes whose Row Source changes based on a selection in a previous combo box. Some are simple Add Item, while most are filled from SQL statements. I had one working, but the next time I tried (no changes), it would not fill the next combo box. Below is the code for the user form. I don't know if I am doing something wrong nesting Select Case statements, or what. I have tried googling a solution, but there are not any examples of what I am trying to do. My lack of knowledge and experience has me seaching blindly. Any suggestions would be great.

    Code:
    Option Compare Database
    Option Explicit
    'Private Sub ReportsChartsClear()
    '    Me.cboRptType.Value = "Select Report or Chart Type"
    '    Me.cboConstraint.RowSource = ""
    '    Me.cboConstraint.Value = "Select Contraint"
    '    Me.cboConValue.RowSource = ""
    'End Sub
    'Private Sub frmReportsCharts_Load()
    '    ReportsChartsClear
    'End Sub
    'Private Sub frmReportsCharts_GotFocus()
    '    ReportsChartsClear
    'End Sub
    Private Sub cmdHome_Click()
        DoCmd.Close acForm, Me.Name
        DoCmd.OpenForm "frmHome"
    End Sub
    Private Sub cboRptType_Change()
        Select Case Me.cboRptType.Value
            Case "Pareto Chart"
               cboConstraint.AddItem "Event Type"
               cboConstraint.AddItem "Event Category"
               cboConstraint.AddItem "Work Area/Cell"
               cboConValue.Enabled = False
               txtStartDate.Enabled = False
            Case "RCA Event Report"
                cboConstraint.AddItem "Work Order #"
                cboConstraint.AddItem "Quality #"
                cboConValue.Enabled = True
                txtStartDate.Enabled = False
            Case "RCA Event Summary List"
                cboConstraint.AddItem "Specific Date to Present"
                cboConstraint.AddItem "Work Area/Cell"
                cboConstraint.AddItem "Event Type"
                cboConstraint.AddItem "Event Category"
        End Select
    End Sub
    Private Sub cboConstraint_AfterUpdate()
        Dim strEventSQL As String
        Dim strSummarySQL As String
        Dim strParetoSQL As String
        Dim RstCount As Integer
        Dim dtmStart As Date
        Dim qdf As DAO.QueryDef
        
        Me.txtStartDate.Text = dtmStart
        'strEventSQL , strSummarySQL, strParetoSQL, strConValue.RowSource = ""
         
        Select Case Me.cboRptType.Value
            Case "RCA Event Summary List"
                MsgBox "This option generates a Summary Report based on non-exclusive criteria. All records meeting this non-exclusive criteria will be displayed."
                Select Case Me.cboConstraint.Value
                    Case "Specific Date to Present"
                        Me.txtStartDate.Visible = True
                        Me.cboConValue.BackColor = RGB(255, 255, 0)
                        Me.cboConValue.Text = "Multiple Records Report"
                        Me.cboConValue.Locked = True
                        strSummarySQL = "SELECT (*) FROM RCAData1 WHERE RCAData1.StartDate > '" & Me.txtStartDate.Value & "' ORDER BY RCAData1.DefectDate DESC;"
                    Case "Part Number"
                        strSummarySQL = "SELECT RCAData1.PartNo FROM RCAData1 ORDER BY RCAData1.DefectDate DESC;"
                        Me.cboConValue.RowSource = strSummarySQL
                        Me.cboConValue.Requery
                    Case "Work Area/Cell"
                        strSummarySQL = "SELECT DISTINCT RCAData1.AreaCell FROM RCAData1 ORDER BY RCAData1.AreaCell DESC;"
                        Me.cboConValue.RowSource = strSummarySQL
                        Me.cboConValue.Requery
                    Case "Event Type"
                        strSummarySQL = "SELECT DISTINCT RCAData1.Type FROM RCAData1 ORDER BY RCAData1.Type DESC;"
                        Me.cboConValue.RowSource = strSummarySQL
                        Me.cboConValue.Requery
                    Case "Event Category"
                        strSummarySQL = "SELECT DISTINCT RCAData1.Category FROM RCAData1 ORDER BY RCAData1.Category DESC;"
                        Me.cboConValue.RowSource = strSummarySQL
                        Me.cboConValue.Requery
                End Select
            Case "RCA Event Report"
                Select Case Me.cboConstraint.Value
                    Case "Work Number #"
                        strEventSQL = "SELECT RCAData1.WorkOrderNo FROM RCAData1 ORDER BY RCAData1.DefectDate DESC;"
                        Me.cboConValue.RowSource = strEventSQL
                        Me.cboConValue.Requery
                    Case "Quality #"
                        strEventSQL = "SELECT RCAData1.QualityNo FROM RCAData1 ORDER BY RCAData1.DefectDate DESC;"
                        Me.cboConValue.RowSource = strConstraintSQL
                        Me.cboConValue.Requery
                End Select
            Case "Pareto Chart"
                Select Case Me.cboConstraint.Value
                    Case "Work Area/Cell"
                        strParetoSQL = "SELECT RCAdata1.AreaCell, COUNT(*) as 'Number of Events' FROM RCAData1 GROUP BY RCAData1.AreaCell;"
                    Case "Event Type"
                        strParetoSQL = "SELECT RCAdata1.EventType, COUNT(*) as 'Number of Events' FROM RCAData1 GROUP BY RCADAta1.EventType;"
                    Case "Event Category"
                        strParetoSQL = "SELECT RCAdata1.Category, COUNT(*) as 'Number of Events' FROM RCAData1 GROUP BY RCAData1.Category;"
                End Select
        End Select
        
    End Sub
    Private Sub cmdGenRpt_Click(ByVal strEventSQL As String, ByVal strSummarySQL As String, ByVal strParetoSQL As String)
        Dim intQty As Integer
        Dim RstCount As Integer
        Dim dtmStart As Date
        Select Case Me.cboRptType.Value
            Case "Pareto Chart"
                DoCmd.Close acForm, Me.Name, acSaveNo
                DoCmd.OpenReport "ParetoChart", , , strParetoSQL
            Case "RCA Event Report"
                DoCmd.Close acForm, Me.Name, acSaveNo
                DoCmd.OpenReport "RCAEventReport", , , strEventSQL
            Case "RCA Event Summary List"
                DoCmd.Close acForm, Me.Name, acSaveNo
                DoCmd.OpenReport "RCASummaryReport", , , strSummarySQL
         End Select
    End Sub


  2. #2
    Rod is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    Difficult to help from the information supplied. 'Option Explicit' - good! Does it compile - I assume so. Have you tried putting in a checkpoint and stepping through the code? Using the On_Change event for a combo box is an unusual choice but won't produce the effect you're experiencing. Nested Select Case statements should be no problem. Are you sure your SQL returns a result set? No date comparisons that I can see so that difficulty does not happen.

    Where do you empty the rows of cboConstraint? I see where you add items but not where you clear/empty them.

    Really this is a case for detailed debugging.

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

Similar Threads

  1. Combo Box auto fill and update table
    By memmons in forum Access
    Replies: 4
    Last Post: 09-27-2012, 11:58 AM
  2. auto fill text box from dependent combo box
    By tommyried in forum Access
    Replies: 6
    Last Post: 06-17-2012, 03:55 PM
  3. combo box to fill listbox
    By accesshelpme in forum Access
    Replies: 4
    Last Post: 05-19-2012, 04:10 PM
  4. Creating a auto fill from a combo box
    By Trina76 in forum Forms
    Replies: 4
    Last Post: 02-07-2012, 02:43 PM
  5. Using a combo box to fill in other fields
    By mccluein in forum Access
    Replies: 1
    Last Post: 03-14-2011, 05:40 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