Expression is typed incorrectly or . . . . change to variables

  • Thread starter Thread starter seeker
  • Start date Start date
S

seeker

The following sql code gives the familiar error found in the subject line.

PARAMETERS [forms]![frmdaterangeforledgerreport]![txtstartdate] DateTime,
[forms]![frmdaterangeforledgerreport]![txtenddate] DateTime;
SELECT TRANSACTIONS.[TRA:TRANSTYPE], TRANSACTIONS.[TRA:NUMBER],
TRANSACTIONS.[TRA:DATE], TRANSACTIONS.[TRA:TOWHOM],
TRANSACTIONS.[TRA:AMOUNT], TRANSACTIONS.[TRA:ACCTBAL],
TRANSACTIONS.[TRA:CODING]
FROM TRANSACTIONS
WHERE
(((TRANSACTIONS.[TRA:DATE])>=[Forms]![frmDateRangeforledgerreport]![txtStartDate]
And
(TRANSACTIONS.[TRA:DATE])<=[Forms]![frmDateRangeforledgerreport]![txtEndDate]))
OR (((TRANSACTIONS.ID) In ("select min([id]) -1 from transactions where
[tra:date] >=# " & [Forms]![frmDateRangeforledgerreport]![txtStartDate] & "#
And <= #" & [Forms]![frmDateRangeforledgerreport]![txtEndDate] & "#"))) OR
(((TRANSACTIONS.ID) In ("select max([id]) +1 from transactions where
[tra:date] >= #" & [Forms]![frmDateRangeforledgerreport]![txtStartDate] & "#
And <= #" & [Forms]![frmDateRangeforledgerreport]![txtEndDate] & "#")));

I have the parameters in the parameter box. Thanks.
 
Try getting rid of all the quotes and & and #:

PARAMETERS [forms]![frmdaterangeforledgerreport]![txtstartdate] DateTime,
[forms]![frmdaterangeforledgerreport]![txtenddate] DateTime;
SELECT TRANSACTIONS.[TRA:TRANSTYPE], TRANSACTIONS.[TRA:NUMBER],
TRANSACTIONS.[TRA:DATE], TRANSACTIONS.[TRA:TOWHOM],
TRANSACTIONS.[TRA:AMOUNT], TRANSACTIONS.[TRA:ACCTBAL],
TRANSACTIONS.[TRA:CODING]
FROM TRANSACTIONS
WHERE
(((TRANSACTIONS.[TRA:DATE])>=[Forms]![frmDateRangeforledgerreport]![txtStartDate]
And
(TRANSACTIONS.[TRA:DATE])<=[Forms]![frmDateRangeforledgerreport]![txtEndDate]))
OR (((TRANSACTIONS.ID) In (select min([id]) -1 from transactions where
[tra:date] >= [Forms]![frmDateRangeforledgerreport]![txtStartDate]
And <= [Forms]![frmDateRangeforledgerreport]![txtEndDate] ))) OR
(((TRANSACTIONS.ID) In (select max([id]) +1 from transactions where
[tra:date] >= [Forms]![frmDateRangeforledgerreport]![txtStartDate]
And <= [Forms]![frmDateRangeforledgerreport]![txtEndDate])));
 
Back
Top