Results 1 to 4 of 4
  1. #1
    Cheshire101 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    42

    Question Filter a subform based on mainform

    OK...please someone help
    I am using a record source select query for a subform. I want the subform to have filters based on several option button on the main form.
    To accomplish this I thought I could use an if statement under each field that can be filtered, below is the working if statement:

    IIf([Forms]![MainForm]![OptionFilter]=True,-1,0)



    problem is if the filter is false I want all data to displayed not just the false data, but if I use:

    IIf([Forms]![MainForm]![OptionFilter]=True,-1,0 OR -1)

    no go...

  2. #2
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    well the syntax of the IIF statement won't work with that OR thrown in. am unclear as to where you are putting the IIF statement(s) - but rather than address that with more detail I'm tempted to change approach and wondering if you have considered modifying your query that serves as the record source for the subform - so that it is calling those values from the main form as its criteria? It strikes me as an approach to consider.

    Hope this helps.

  3. #3
    Cheshire101 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    42
    Ok th IIF statement is in the criteria area for that field. I can not just make this permanent because it is based on whether the option button is selected or not. Also there are several of these option buttons see example below

    Option Button A (Selected) then the subform will update with records for which a specific field is true.

    Option Button B (Selected) then the subform will update with records for which a specific field is true.

    If both are selected then the subform will update with records for which both specifc fields are true.

    The IIF statement that works will do this with the except that if the option button is not selected it gives me just the data for which the specific field is false (what I need is both true and false if the option button is not selected)

  4. #4
    Cheshire101 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    42
    Well I fixed my own problem...lets here for being self sufficient

    The IIF statement needs to be:
    IIf([Forms]![MainForm]![OptionFilter]=True,-1,0) Or True
    ** This way the true values are always present

    Instead of:
    IIf([Forms]![MainForm]![OptionFilter]=True,-1,0 OR -1)

    Thanks any way guys and girls...

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

Similar Threads

  1. Replies: 1
    Last Post: 11-16-2010, 08:42 AM
  2. Replies: 5
    Last Post: 10-06-2010, 07:28 PM
  3. Replies: 0
    Last Post: 03-14-2009, 12:33 AM
  4. Replies: 1
    Last Post: 03-01-2009, 09:53 AM
  5. copying data from subform to mainform
    By wasim_sono in forum Forms
    Replies: 0
    Last Post: 03-10-2006, 04:35 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