Results 1 to 7 of 7
  1. #1
    mathanraj76 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2013
    Posts
    39

    select more then one magazine

    Hi..

    I have a problem on my database

    I have 2 combobox name cbomagazine1 and cbomagazine2 with two command buttons name cmdSearch and cmdViewQuery

    Wht i doing here is
    first i select magazine name from cbomagazine1 and select magazine name from cbomagazine2 and click the button cmdSearch
    one it's show me the filter result then i click cmdViewQuery to sent the data which filter into my query.

    for an example
    select first cbomagazine2="CAR" and second cbomagazine2=" STYLE" and click the cmdSearch it should filter and the show the result on my subform

    some customer might have on magazine and some customers might have more then one magazine

    I having a problem on here ..
    I don't know how do this ..

    i have attached sample database
    Thanks
    Mathanraj
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    This is similar to issue in post https://www.accessforums.net/program...tml#post174383

    "WHERE M" & Me.cbomagazine1 & "='" & Me.cbomagazine1 "' OR M" & Me.cbomagazine2 & "='" & me.cbomagazine2 & "'" & _
    " ORDER BY M" & Me.cbomagazine1 & ", M" & Me.cbomagazine2 & ";"

    As has been noted already, this non-normalized structure will continually be a source of difficulty.
    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
    mathanraj76 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2013
    Posts
    39
    I just want how many customer may have more then one magazine according to the selection from the both combobox which have in my forms
    This is not by quantity but by magazine name
    I do this in sql by using the toggle filter but i don't know how to use in vba

    the coding which u give me shows error "compile error: expected: end of statement"

    Thanks
    Mathanraj

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Sorry, missing an &. The debugger should highlight the text where the error is. Put an & just in front of the highlighted text which should be: "' OR M"
    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.

  5. #5
    mathanraj76 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2013
    Posts
    39
    hi ..
    i have problem on source code..
    when i run both cbomag for rest of the fields is working fine for me expect the qryall.Qmensuno and qryall.Mmensuno it's show nothing..

    I have attached the codes

    for an example
    if cbomag = "style" and cbomag1 ="intrend" it's show result in query table
    if cbomag = "mensuno" and cbomag1 ="intrend" no result shows in query table
    if cbomag = "mensuno" and cbomag1 ="mensuno" no result shows in query table

    other then "Mensuno" the the source code can give the result in query table

    Thanks
    Mathanraj
    Attached Files Attached Files

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Code for the query def:
    Code:
    Set db = CurrentDb
    If Not QueryExixts("tbltesting") Then
        Set qdf = db.CreateQueryDef("tbltesting")
    Else
        Set qdf = db.QueryDefs("tbltesting")
    End If
     If Not IsNull(Me.cbomagazine1) Then
         strMag = "M" & Me.cbomagazine1 & "='" & Me.cbomagazine1 & "'"
     End If
     If Not IsNull(Me.cbomagazine2) Then
         strMag = strMag & IIf(strMag <> "", " OR ", "") & "M" & Me.cbomagazine2 & "='" & Me.cbomagazine2 & "'"
     End If
     qdf.SQL = "SELECT qryall.* FROM qryall " & _
         "WHERE " & strMag & _
         IIf(Not IsNull(Me.cbomagazine1) Or Not IsNull(Me.cbomagazine2), " ORDER BY ", "") & _
         IIf(Not IsNull(Me.cbomagazine1), "M" & Me.cbomagazine1, "") & _
         IIf(Not IsNull(Me.cbomagazine1) And Not IsNull(Me.cbomagazine2), ", ", "") & _
         IIf(Not IsNull(Me.cbomagazine2), "M" & Me.cbomagazine2, "") & ";"
    Code for the form search:
    Code:
     Me.qryall_subform.Requery
     Me.qryall_subform.Form.FilterOn = False
     Me.qryall_subform.Form.Filter = "[M" & Me.cbomagazine1 & "]='" & Me.cbomagazine1 & "' OR [M" & Me.cbomagazine2 & "]='" & Me.cbomagazine2 & "'"
     Me.qryall_subform.Form.FilterOn = True
    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.

  7. #7
    mathanraj76 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2013
    Posts
    39
    Thanks ..
    That's what i really looking for.
    and u have save time ..

    U r really very good ..expert..
    But m..not..
    I still learning all the new things..

    U have solved my problem..

    Thanks
    Mathanraj

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

Similar Threads

  1. Replies: 1
    Last Post: 10-08-2012, 09:01 AM
  2. Replies: 5
    Last Post: 07-26-2012, 12:59 PM
  3. Replies: 8
    Last Post: 04-21-2011, 05:29 PM
  4. Replies: 4
    Last Post: 03-17-2011, 06:17 AM
  5. Replies: 1
    Last Post: 10-22-2010, 10:11 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