Results 1 to 7 of 7
  1. #1
    Jmoore86 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2013
    Posts
    9

    Microsoft database engine does not recognize " as a valid field or expression

    Hi Guys,


    As per the title - I have a crosstab query with a date field (Collection Date) where i've got a parameter [Enter Date] to force the user to specify an individual date which will filter the crosstab query. This works perfectly (yay Access) however, when I try to run a report that uses said crosstab query as its data source, I get prompted a few times for a parameter then i'm left with the very annoying "Microsoft database engine does not recognize " as a valid field or expression" message.

    The SQL for my crosstab is:

    Code:
    PARAMETERS [Enter Date] DateTime;
    TRANSFORM Sum(qryProductsPerDay.Expr1) AS SumOfExpr1
    SELECT qryProductsPerDay.[Collection Date], qryProductsPerDay.Product_Name, qryProductsPerDay.Quantity, qryProductsPerDay.UOM, Count(qryProductsPerDay.Expr1) AS [Total Of Expr1]
    FROM qryProductsPerDay
    WHERE (((qryProductsPerDay.[Collection Date])=[Enter Date]))
    GROUP BY qryProductsPerDay.[Collection Date], qryProductsPerDay.Product_Name, qryProductsPerDay.Quantity, qryProductsPerDay.UOM
    PIVOT qryProductsPerDay.[Platter Name];
    As I say, this works perfectly when running the query on its own. The "Collection Date" text box on my report has the following text in it (created by the report wizard, not me) "=Format$([Collection Date],"Long Date",0,0)" Is this where my issue lies?

    As ever - thanks very much for looking into this for me!

    Jon

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    its very difficult to bind a report to a Xtab query, since the fieldname can be random and wont match the boxes in the report.
    Unless you make a box for every possible outcome of the xtab query.

    usu. xtab queries are viewed best as datasheets.

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Disagree completely.
    If you know the headings e.g Jan to Dec you can set fixed column headings.
    However where the headings are dynamic, it is fairly simple to write code to manage that.

    I have many examples of reports based on dynamic crosstab headings. See these links for two examples
    http://www.mendipdatasystems.co.uk/cert/4594365453
    http://www.mendipdatasystems.co.uk/e...ies/4594398115
    Very similar code is used in the reports in each of those example apps and can be used in forms as well (continuous or datasheet)
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  4. #4
    Jmoore86 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2013
    Posts
    9
    Cheers, Ridders.

    I know that there can/ will be up to 15 possible headings and they are all predictable; they're all dates from 18th - 31st December 2018. What's the process for setting these fixed column headings?

    Thanks again!

  5. #5
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Answering on my phone as we have no power for most of today.
    You only need to specify headings if you want all columns to appear even if there is no data in some.
    To do so, enter the values in the Column Headers part of the query property sheet
    You need to separate each with a semicolon
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  6. #6
    Jmoore86 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2013
    Posts
    9
    No power sounds grim! Cheers for the effort

    I've got the report to run OK - but when I try and filter via a parameter on the crosstab query, it works fine, but doesn't on the report. I'm entering a valid date but it just doesn't seem to accept it... the field is used as a grouping within the report, if that makes a difference?

  7. #7
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Try removing the field from the grouping temporarily.
    If you can't find a solution, post a stripped down version and I'll look at it later when I can do so ... unless someone else does so first
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Replies: 6
    Last Post: 02-23-2018, 12:16 PM
  2. Replies: 4
    Last Post: 01-24-2017, 09:32 AM
  3. Replies: 13
    Last Post: 05-03-2016, 08:44 AM
  4. Replies: 4
    Last Post: 05-22-2015, 02:29 AM
  5. Replies: 1
    Last Post: 05-06-2015, 03:33 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