Results 1 to 4 of 4
  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

    Queries based on a Select Case

    I have the following code for deciding which query to run to populate a combo box. I have tried plugging the SQL directly into the Row Source on the property sheet of the combo box and they work fine. When I try to do this in the procedure itself, it seems not to query at all (the combo box stays empty). Syntactically, everything seem to work fine.



    Code:
    Private Sub cboConValue_AfterUpdate()
    strPatretoSQL As String
    strEventReportSQL As String
    strEventSummarySQL As String
    strParetoSQL = ""
    strEventReportSQL = ""
    strEventSummary = ""
    Me.cboConValue.RowSource = ""
    Me.txtStartDate.Visible = False
    Select Case Me.fraReport.Value
    Case 1
    Select Case Me.cboConstraint.Value
    Case "Work Order #"
    strEventReportSQL = "SELECT RCAData1.WorkOrderNo FROM RCAData1 ORDER BY RCAData1.DefectDate;"
    Me.cboConValue.RowSource = strEventTypeSQL
    DoCmd.strEventType.Requery
    Case "Quality #"
    strEventReportSQL = "SELECT RCAData1.QualityNo FROM RCAdata1 ORDER BY RCAData1.DefectDate;"
    DoCmd.strEventType.Requery
    End Select
    Case 2
    Select Case Me.cboConstraint.Value
    Case "Event Type"
    strSummaryReportSQL = "SELECT DISTINCT RCAData1.Type FROM RCAData1;"
    DoCmd.OpenReport "RCASummaryReport", , , strSummaryReportSQL
    DoCmd.Close acForm, Me.Name, acSaveNo
    Case "Event Category"
    strSummaryReportSQL = "SELECT DISTINCT RCAData1.Category FROM RCAData1;"
    DoCmd.OpenReport "RCASummaryReport", , , strSummaryReportSQL
    DoCmd.Close acForm, Me.Name, acSaveNo
    Case "Work Area/Cell"
    strSummaryReportSQL = "SELECT DISTINCT RCAData1.AreaCell FROM RCAData1;"
    DoCmd.OpenReport "RCASummaryReport", , , strSummaryReportSQL
    DoCmd.Close acForm, Me.Name, acSaveNo
    End Select
    Case 3
    Select Case Me.cboConValue.Value
    Case "Specific Date to Present"
    Me.txtStartDate.Visible = True
    strParetoSQL = ""
    Case "Work Area/Cell"
    strParetoSQL = ""
    Case "Event Type"
    strParetoSQL = ""
    Case "Event Category"
    strParetoSQL = ""
    End Select
    End Select
    End Sub
    I do know that the SQL statments for the Pareto chart are not in. I am not trying to use them at this time. I am not sure where I am going wrong. Suggestions?
    Last edited by dccjr; 03-05-2013 at 03:20 PM. Reason: typos

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Looking only at the first:


    Case "Work Order #"
    strEventReportSQL = "SELECT RCAData1.WorkOrderNo FROM RCAData1 ORDER BY RCAData1.DefectDate;"
    Me.cboConValue.RowSource = strEventTypeSQL

    See anything off?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    dccjr's Avatar
    dccjr is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Colorado Springs, CO
    Posts
    138
    Thanks. I'll just hang my head in shame now.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    We've all done it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. VBA for SELECT CASE logic
    By rlsublime in forum Programming
    Replies: 1
    Last Post: 12-04-2012, 09:09 PM
  2. select case problem
    By Mclaren in forum Programming
    Replies: 3
    Last Post: 11-17-2011, 01:28 PM
  3. select case or else if for unhiding
    By nichmeg in forum Programming
    Replies: 3
    Last Post: 10-30-2011, 09:30 AM
  4. Select Case vs Dlookup
    By BRV in forum Programming
    Replies: 1
    Last Post: 10-28-2011, 03:18 PM
  5. Help with Select Case statement
    By focosi in forum Access
    Replies: 4
    Last Post: 08-09-2011, 12:01 AM

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