Make a table query

W

Wahab

Hi
I wnat to write sql to make a table query , I copied the
sql on command button but it is giving me an error,
please help me how I will make this, here is my sql :

"PARAMETERS [forms]![Startup Dialog McDonaldsReports]!
[StartQuarter] DateTime, [forms]![Startup Dialog
McDonaldsReports]![EndQuarter] DateTime;
SELECT McDonaldCustomers.Status,
McDonaldCustomers.CustomerName,
NapkinsSalesDetails.TotalSalesKD, IIf(DatePart
("q",NapkinsSalesDetails!Date)=1,"1st Quarter",IIf
(DatePart("q",NapkinsSalesDetails!Date)=2,"2nd
Quarter",IIf(DatePart("q",NapkinsSalesDetails!Date)
=3,"3rd Quarter","4th Quarter"))) AS Quarter INTO
[McDonald PriceHistory Table]
FROM (Invoices INNER JOIN NapkinsSalesDetails ON
Invoices.InvoiceNo = NapkinsSalesDetails.InvoiceNo) INNER
JOIN McDonaldCustomers ON Invoices.CustomerID =
McDonaldCustomers.CustomerId
WHERE (((NapkinsSalesDetails.Date) Between [forms]!
[Startup Dialog McDonaldsReports]![StartQuarter] And
[Forms]![Startup Dialog McDonaldsReports]![EndQuarter]));

thanks in advance
 
M

Michel Walsh

Hi,


You have to double the " already inside the statement:


str= "...IIf(DatePart ("q",NapkinsSalesDetails!Date)=1,"1st Quarter", IIf
.... "


should be


str= "...IIf(DatePart (""q"",NapkinsSalesDetails!Date)=1,""1st Quarter"",
IIf ... "




Other things can go wrong too (that is not necessary the only problem).
Wihtout context, it is hard to tell.


Hoping it may help,
Vanderghast, Access MVP
 

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