Results 1 to 8 of 8

Thread: MS Access 2016 Report "WhereCondition" not being applied

  1. #1

    Thread Starter
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    MS Access 2016 Report "WhereCondition" not being applied

    I have the following code, yet, the report is never filtered; I get all records in the database. While I've tried various syntax options, nothing seems to work. This leads me to believe I'm looking at a problem not related to syntax.

    strWhere = "ShipperID = " & Me.cmbShipperList.Value
    DoCmd.OpenReport "rptAllSignDataByJob", acPreview, , strWhere

    An important note is that this report is based upon an extremely complex query with many types of querries and tables included.

    Technically, the field name "ShipperID" is from tblStationStatus and thus you would think referring to it is "tblStationStatus.ShipperID" would work, but the field name in the existing fields list is simply "ShipperID". Regardless, neither works.

    I just want to open the filtered report and keep the parameters out of the query.

    Thanks, in advance.
    Things I've found useful:
    DateTime.ToString() Patterns | Retrieving and Saving Data in Databases | ADO.NET Data Containers: An Explanation

    Quote of the day from jmcilhinney:
    'Talking about Option Strict and Option Explicit in the same sentence is pointless unless it is to say that they should both be On.'

  2. #2
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,206

    Re: MS Access 2016 Report "WhereCondition" not being applied


  3. #3

    Thread Starter
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    Re: MS Access 2016 Report "WhereCondition" not being applied

    Quote Originally Posted by wes4dbt View Post
    Is this link to suggest that I should use OpenArgs or to show me proper formatting syntax? I'm not currently using OpenArgs and do not completely understand them. Although, I could easily search on how to, just wanted to make sure that is what you were getting at.
    Things I've found useful:
    DateTime.ToString() Patterns | Retrieving and Saving Data in Databases | ADO.NET Data Containers: An Explanation

    Quote of the day from jmcilhinney:
    'Talking about Option Strict and Option Explicit in the same sentence is pointless unless it is to say that they should both be On.'

  4. #4
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,206

    Re: MS Access 2016 Report "WhereCondition" not being applied

    Quote Originally Posted by jazFunk View Post
    Is this link to suggest that I should use OpenArgs or to show me proper formatting syntax? I'm not currently using OpenArgs and do not completely understand them. Although, I could easily search on how to, just wanted to make sure that is what you were getting at.
    Not at all, it about using ' around your sting value. One of the post shows the proper syntax for various data types.

    edit - maybe I'm wrong and ShippId is a number.
    Last edited by wes4dbt; Aug 25th, 2018 at 03:19 PM.

  5. #5

    Thread Starter
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    Re: MS Access 2016 Report "WhereCondition" not being applied

    Quote Originally Posted by wes4dbt View Post
    Not at all, it about using ' around your sting value. One of the post shows the proper syntax for various data types.
    I see. But the value for ShipperID in the database is an integer. I've also tried converting the combobox value to an integer, but still nothing gets applied.

    I've found this link which states if my query already has a Where condition, I cannot use the WhereCondition of the report. This may be my problem and I may need to use FilterName instead. But, I don't quite get it, either. it looks like it needs to refer to an existing query.. not sure I understand.

    https://www.tek-tips.com/viewthread.cfm?qid=592834

    Here's the quote from the link:

    "The Where parameter is Before the RecordSource is applied. The Filter property is After.

    The Filter and Where condition are NOT the same thing. With a Filter, the Recordsource is used as is, i.e., the report query is run as given. All the records are then returned but only those that match the Filter are passed onto the report for further processing.

    With a Where, it's as if a Where clause was tacked onto the end of the RecordSource. The RecordSource with this new Where clause appended to it is then used as the report's actual query.

    If the RecordSource already has a Where clause or if it ends in some other clause that mornally follows the Where (Group By, Having, etc.), the OpenReport Where parameter won't work correctly. You can't tack on a Where clause at the end if it doesn't normally belong there."

    I believe this is my problem.
    Things I've found useful:
    DateTime.ToString() Patterns | Retrieving and Saving Data in Databases | ADO.NET Data Containers: An Explanation

    Quote of the day from jmcilhinney:
    'Talking about Option Strict and Option Explicit in the same sentence is pointless unless it is to say that they should both be On.'

  6. #6

    Thread Starter
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    Re: MS Access 2016 Report "WhereCondition" not being applied

    Deleted Text
    Last edited by jazFunk; Aug 25th, 2018 at 03:25 PM. Reason: Posted twice. No idea why. Deleted text as I can't delete post.
    Things I've found useful:
    DateTime.ToString() Patterns | Retrieving and Saving Data in Databases | ADO.NET Data Containers: An Explanation

    Quote of the day from jmcilhinney:
    'Talking about Option Strict and Option Explicit in the same sentence is pointless unless it is to say that they should both be On.'

  7. #7
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,206

    Re: MS Access 2016 Report "WhereCondition" not being applied

    Sounds reasonable. I'm not an expert on MS Access reports, I just thought perhaps ShipperID was a string and the missing ' was your problem. Good luck

  8. #8

    Thread Starter
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    Re: MS Access 2016 Report "WhereCondition" not being applied

    Quote Originally Posted by wes4dbt View Post
    Sounds reasonable. I'm not an expert on MS Access reports, I just thought perhaps ShipperID was a string and the missing ' was your problem. Good luck
    Appreciate the input, as always. Wish it was that simple. That kind of error still gets me occasionally, to this day.
    Things I've found useful:
    DateTime.ToString() Patterns | Retrieving and Saving Data in Databases | ADO.NET Data Containers: An Explanation

    Quote of the day from jmcilhinney:
    'Talking about Option Strict and Option Explicit in the same sentence is pointless unless it is to say that they should both be On.'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width