Results 1 to 2 of 2
  1. #1
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276

    Help Me fix a Report Using Cascading Combo Boxes

    I have made a Cascading Combo Boxes form
    this form has 3 combo boxes
    its working perfectly

    i have to select items in all 3 combo boxes to get a report.

    what i want is, if i do not select (leave empty) any item in the third combo box it should give me the report for all the items in the third combo box "Me.SubDesCbo"

    how can I do that

    I am using the following code:

    Private Sub cmdOpenReportSingle_Click()

    On Error GoTo Err_Handler

    Const REPORTNAME = "Yarn Report"
    Const MESSAGETEXT = "All Combo's Must Be Selected."
    Dim strCriteria As String

    ' build string expression to filter report
    ' to selected customer and account
    strCriteria = "[ProcessingStatus] = """ & Me.sldcbo & """" & _
    " And [YarnType] = """ & Me.TypeCbo & """" & _
    " And [ProcessingSubdescription] = """ & Me.SubDesCbo & """"

    ' make sure a customer is selected
    If Not IsNull(Me.TypeCbo) And Not IsNull(Me.SubDesCbo) Then
    ' open report filtered to selected customer
    DoCmd.OpenReport REPORTNAME, _
    View:=acViewPreview, _


    WhereCondition:=strCriteria
    Else
    MsgBox MESSAGETEXT, vbExclamation, "Invalid operation"
    End If

    Exit_Here:
    Exit Sub

    Err_Handler:
    MsgBox Err.Description, vbExclamation, "Error"
    Resume Exit_Here

    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Either use parameterized query with wildcards as shown in this tutorial: http://www.datapigtechnologies.com/f...mtoreport.html

    Or use conditional If to build the sql string. If control is null, don't concatenate it into the string.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Cascading combo boxes
    By Jackie in forum Access
    Replies: 5
    Last Post: 07-26-2013, 09:07 AM
  2. Sum of Cascading Combo Boxes
    By alonewolf23 in forum Forms
    Replies: 2
    Last Post: 11-20-2011, 02:10 PM
  3. Cascading combo boxes
    By combine21 in forum Forms
    Replies: 3
    Last Post: 12-02-2010, 12:57 PM
  4. Cascading Combo Boxes
    By desireemm1 in forum Programming
    Replies: 1
    Last Post: 10-05-2009, 06:00 AM
  5. Cascading Combo Boxes
    By gjw1012 in forum Access
    Replies: 1
    Last Post: 07-25-2009, 04:59 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