Results 1 to 10 of 10
  1. #1
    swenger is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2016
    Posts
    151

    Crosstab Query based on input crieria

    I created a Crosstab Query which is based on another simple query. The simple query has a criteria which is a text box on a form.

    When I run the Crosstab I get an error that the Criteria is not a valid field. However, if I run the simple query alone it works. Also if I insert hard coded value in the simple query, the crosstab works.

    Any ideas how to get this to work how I want it to.



    Thanks

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    you probably need to declare the textbox as a parameter (which specifies the data type)

    on the ribbon in query design view, click on the parameters option, enter the name of the form field as you have for the criteria and specify the data type (text, long, whatever). In sql view you would see something like

    PARAMETERS [Forms]![myForm]![myControl] Long;
    SELECT....

    note the semi colon at the end of the parameter line

  3. #3
    swenger is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2016
    Posts
    151
    I tried that. The error message I get is "The Microsoft Access database engine does not recognize '[Forms]![Report]![SP]' as a valid field name or expression

    My SQL first line is as follows

    PARAMETERS Period Text ( 255 );

  4. #4
    swenger is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2016
    Posts
    151
    When I run the Simple query alone now instead of running it first gives me a prompt "Enter Parameter Value" with "Period" which only happened after I entered the Parameters as you mentioned.

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    Report is a reserved word so calling your form that may be causing issues.

    Also, the form does need to be open with a textbox called SP

  6. #6
    swenger is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2016
    Posts
    151
    The form is actually called FReport. I used that for simplicity. The form is open and has SP

  7. #7
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    well all I can say is it works in 2010 - perhaps provide your full sql

  8. #8
    swenger is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2016
    Posts
    151
    It is a rather large Database, so I created a new file and exported the neccessary data to replicate my issue which I have uploaded. You will see in the QsumbyIssues Query the last column if I add Period:<Formula> and then add this to the Paramater, when I run the query it prompts me for the Period. If I do not add the Parameter the query runs but the Crosstab Query gives an error.

    Thanks,Test.accdb

  9. #9
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    in the QsumbyIssues Query I added the parameters as I suggested and it worked fine

    PARAMETERS [Forms]![FReports]![SP] Text ( 255 ), [Forms]![FReports]![EP] Text ( 255 );
    SELECT QTickets.[Issue Type....

  10. #10
    swenger is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2016
    Posts
    151
    Thank you. I thought you meant to type the field name in the parameter. Didn't realize to put the criteria field from the form in the parameter

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

Similar Threads

  1. Replies: 1
    Last Post: 03-26-2016, 08:23 PM
  2. Replies: 2
    Last Post: 06-09-2012, 07:59 AM
  3. Report based on crosstab query
    By pbuecken in forum Reports
    Replies: 7
    Last Post: 01-16-2012, 09:59 PM
  4. Count and crieria on Report question
    By AndycompanyZ in forum Reports
    Replies: 7
    Last Post: 08-10-2011, 06:54 AM
  5. Replies: 1
    Last Post: 07-30-2010, 10:28 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