Results 1 to 4 of 4
  1. #1
    coilerDH is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    13

    Need help understanding a line of code.

    I am working on a DB that I did not create. I am not understanding a line of code and could use some input.
    DoCmd.OpenReport "Monthly Reports Due", acViewPreview, , IIf(subMonthlyReportsDue.Form.FilterOn, subMonthlyReportsDue.Form.Filter, "")


    IIf(subMonthlyReportsDue.Form.FilterOn, subMonthlyReportsDue.Form.Filter, "") this part is where I m not completely sure what it is saying. I don't know if this requires more background on the project to give an explanation.
    Thanks.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    It's an IIf conditional expression. It is setting the report WHERE condition argument based on the form filter. An IIf() has the follow syntax:

    IIf(expression that evaluates to true or false, do this if expression is true, do this if expression is false)

    FilterOn property is either True or False.

    IF form FilterOn property is True THEN use expression from the form Filter property ELSE use empty 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.

  3. #3
    coilerDH is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Posts
    13
    If I try and duplicate this in my own DB it does not pass the text filter from the form into the report. That is what this is doing in the DB that I am working. To help me understand what is going on I tried to recreate that functionality in a new DB. What other way can I pass in the text filter to the report using the OpenReport method?
    The stuff I have seen is like this:
    DoCmd.OpenReport "Sales Report", acViewNormal, "Report Filter"

    but the text filter from the data grid view of the report is not a "pre defined" filter.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    That example code is setting the FILTER argument, not the WHERE CONDITION argument. I have never used FILTER argument.

    If the form Filter property is not used to dynamically filter the form then certainly there is nothing to pass to report.

    Normally I pass a value from a field or control on the form.

    DoCmd.OpenReport "report name", , , "ID=" & Me.tbxID
    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. Replies: 1
    Last Post: 11-11-2014, 03:54 PM
  2. Need help in understanding Email Code
    By recyan in forum Access
    Replies: 22
    Last Post: 10-13-2014, 04:03 AM
  3. Replies: 15
    Last Post: 07-29-2014, 06:15 AM
  4. Help understanding code to run query
    By radguy in forum Programming
    Replies: 1
    Last Post: 07-28-2014, 05:42 AM
  5. How to do line by line compare of VB code?
    By Buakaw in forum Access
    Replies: 2
    Last Post: 02-14-2011, 11:46 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