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

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.
 
D

Duane Hookom

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])));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top