Results 1 to 4 of 4
  1. #1
    jasonix is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    3

    how to filter data using two combo boxes?

    I have two combo boxes named TrainingName and CustomerName. what i wanted to do is by selecting a training name and customer name i would be able to search that in my MembersTraining query and print a report. For example i selected "Ben Gonzales" in the CustomerName and "ICT 1" in TrainingName, all of the information about Ben Gonzales in the ICT 1 training will be in that report.

    here's my code.



    Dim stDocName As String

    stDocName = "rptMemberstraining"

    DoCmd.openreport stDocName, acPreview, , "[fld_CustomerNameID]=" & Me!CustomerName.Value And "[fld_TrainingName]=" & Me!TrainingName.Value



    unfortunately this code isn't correct. =(

    thanks.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    If the fields are text datatype, the criteria must be enclosed in apostrophe delimiters, date would need #.

    "[fld_CustomerNameID]=" & Me!CustomerName.Value & " And [fld_TrainingName]='" & Me!TrainingName.Value & "'"
    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.

  3. #3
    jasonix is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    3
    thanks for replying June 7. sorry i forgot that the 2nd combo box is also an Integer. It is fld_TrainingID...

  4. #4
    jasonix is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    3
    got the solution. For those who want to see the solution, here's how. =)

    Dim stDocName As String
    Dim strWhere As String

    stDocName = "rptCustomerTraining"
    strWhere = "[fld_CustomerID]=" & Me!CustomerName.Value & " And [fld_TrainingID]=" & Me!TrainingName.Value & ""

    DoCmd.OpenReport stDocName, acPreview, , strWhere

    i just inserted double qoutes. =)

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

Similar Threads

  1. Replies: 9
    Last Post: 06-04-2014, 10:45 AM
  2. Replies: 0
    Last Post: 06-29-2011, 01:04 PM
  3. Filter based on two combo boxes.
    By jakeao in forum Programming
    Replies: 1
    Last Post: 05-22-2011, 10:56 AM
  4. Filter form from multiple combo boxes
    By Bird_FAT in forum Programming
    Replies: 6
    Last Post: 05-19-2010, 09:32 AM
  5. Using Cascading Combo Boxes to Filter a Query
    By skiptotheend in forum Queries
    Replies: 0
    Last Post: 10-13-2009, 06:57 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