Problem passing in parameter dates from form to query. (Urgent)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dave0291
    New Member
    • Jan 2012
    • 33

    Problem passing in parameter dates from form to query. (Urgent)

    Hi there,

    I have a form with which I enter data. A sort order, start date and end date.

    Once the data is entered, a report is generated. But I get and error.

    Error: "The Microsoft Access database engine does not recognize '[Forms]![AuditPTETotals]![startDate]' as a valid field name or expression.

    This is my crosstab (AuditPTETotals _CrosstabDateRa nge) query which uses the data retrieved by another query (AuditPTETotals DateRange)

    Code:
    TRANSFORM Sum(AuditPTETotalsDateRange.PTEtotal) AS SumOfPTEtotal
    SELECT AuditPTETotalsDateRange.companyName, AuditPTETotalsDateRange.regNum, Sum(AuditPTETotalsDateRange.PTEtotal) AS [Total Of PTEtotal]
    FROM AuditPTETotalsDateRange
    GROUP BY AuditPTETotalsDateRange.companyName, AuditPTETotalsDateRange.regNum
    PIVOT AuditPTETotalsDateRange.description;
    And this is AuditPTETotalsD ateRange

    Code:
    SELECT CUSTOMER.regNum, CUSTOMER.companyName, ScrapTireType.description, ScrapTireType.PTEamount, ScrapCollectionTireType.amount, ScrapCollection.PTEtotal, ScrapCollection.Date
    FROM (ScrapCollection INNER JOIN CUSTOMER ON ScrapCollection.regNum = CUSTOMER.regNum) INNER JOIN (ScrapTireType INNER JOIN ScrapCollectionTireType ON (ScrapTireType.scrapTireTypeID = ScrapCollectionTireType.scrapTireTypeID) AND (ScrapTireType.scrapTireTypeID = ScrapCollectionTireType.scrapTireTypeID)) ON ScrapCollection.scrapCollectionID = ScrapCollectionTireType.scrapCollectionID
    WHERE (((ScrapCollection.Date) Between [Forms]![AuditPTETotals]![startDate] And [Forms]![AuditPTETotals]![endDate]));
    I have used this approach in a similar way to reference forms fields in a query but this time, I am not sure what I'm doing wrong. Please help.

    Thank you
  • TheSmileyCoder
    Recognized Expert Moderator Top Contributor
    • Dec 2009
    • 2322

    #2
    Its been a while since I have referenced form controls in queries, but my suggestion would be:
    Try removing the square brackets you have placed around Forms

    Comment

    • Dave0291
      New Member
      • Jan 2012
      • 33

      #3
      Thanks for the reply but no luck. It's really weird because I have referenced forms fields in queries like this before and have had no problems. Could it be because I am using a query as my source for my cross tab query?

      Comment

      • dsatino
        Contributor
        • May 2010
        • 393

        #4
        If it's a bound field, check to be sure that the field name and the control name aren't the same.

        Comment

        Working...