Results 1 to 4 of 4
  1. #1
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591

    Crosstab Questions

    I'm trying to write what I though would be a simple Cross Tab query and I'm getting this error.
    Microsoft Access database engine does not recognize [Forms]![frm_Chart]![txt_FromDate] as a valid field name or expression.
    [CODE]PARAMETERS [Forms]![frm_Chart]![txt_FromDate] DateTime, [ [Forms]]![frm_Chart]![txt_TillDate] DateTime;
    TRANSFORM Sum(tbl_Production.Production) AS SumOfProduction
    SELECT tbl_Production.[MOD], tbl_Production.Machine, tbl_Production.Shift
    FROM tbl_Production INNER JOIN tbl_Shift ON tbl_Production.Shift = tbl_Shift.Shift
    WHERE (((tbl_Production.ProductionDate) Between CDate([Forms]![frm_Chart]![txt_FromDate]) And CDate([Forms]![frm_Chart]![txt_TillDate])))
    GROUP BY tbl_Production.[MOD], tbl_Production.Machine, tbl_Shift.Shift_Order, tbl_Production.Shift
    PIVOT tbl_Production.ProductionDate;
    CODE]



    I've run the code using the #7/1/2012# format and it runs fine. I also get the same error when I try to use an ordinary parameter prompt, i.e. [From Date] and [Till Date]

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I have never used Parameters clause in a crosstab but then I don't do many crosstabs.

    Review: http://allenbrowne.com/ser-67.html
    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
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    The error occurs whether I declare the Parameters or not. Declaring them was an unsuccessful attempt to solve the problem. The crux of the matter is in the WHERE clause. This works:

    Code:
    WHERE (((tbl_Production.ProductionDate) Between #11/7/2012# And #11/13/2012#))
    and this doesn't.

    Code:
    Between CDate([Forms]![frm_Chart]![txt_FromDate]) And CDate([Forms]![frm_Chart]![txt_TillDate])
    I know the syntax is correct. I've tested it in a Select query.

  4. #4
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    After repeated attempts, I finally got this right. There may, must, be a stray space or mark in my form parameter causing it not to find the specified text box. I just tested again and found this to be the case.
    A space after the final bracket is invisible in the Query Parameters box,
    Code:
    [Forms]![frm_Chart]![txt_FromDate]
    [Forms]![frm_Chart]![txt_TillDate]
    but gets translated as this

    Code:
    PARAMETERS [Forms]![frm_Chart]![[txt_FromDate] ] DateTime, [Forms]![frm_Chart]![txt_TillDate] DateTime;
    in the SQL window. Note the extra brackets. I now see this in the example I posted. Just another one of those surprises from Microsoft Access.

    Happy New Year

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

Similar Threads

  1. Couple of Questions
    By cade1980 in forum Access
    Replies: 2
    Last Post: 04-15-2012, 12:00 PM
  2. QBF Questions
    By brandonze in forum Forms
    Replies: 2
    Last Post: 08-04-2011, 01:49 PM
  3. List box questions
    By SteveL5231 in forum Forms
    Replies: 1
    Last Post: 12-15-2010, 08:43 AM
  4. Few N00b Questions
    By lucas.robb in forum Database Design
    Replies: 2
    Last Post: 09-20-2010, 04:58 PM
  5. First Database Questions...
    By qu1ckdry in forum Database Design
    Replies: 0
    Last Post: 03-01-2010, 09:33 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