L
Lowell Moorcroft
Hello, all -
I'm posting this in both forms programming and queries
newsgroups.
I'm trying to include invoices billed quarterly with
invoices billed monthly if the current month is right
after the end of a quarter (i.e., the number of the month
is 4,7,10, or 1 if the current month is April, July,
October or January)
I'm switching the record set on the invoice report to
reflect this, using an SQL string in the form. I pass the
SQL string from the form to the report through a variable
and that part works fine.
But I'm getting syntex error messages when introducing the
conditional phrasing into an SQL statement to choose
between including the quarterly billings or not. I suspect
it's either too complicated or I'm trying to do something
in SQL not permissible under the .OpenRecordSet method.
I'm also uncertain of the SQL code itself, but it worked
before trying to bring in the conditional code.
I'm also uncertain about extracting the month in Access
SQL.
Here's the SQL:
Set rs = db.OpenRecordset(IF DatePart('m', Date) In
('4','7','10','1') THEN " & _
"SELECT tblTestInvoice.*, tblPayment.Amount" & _
"FROM tblTestInvoice " & _
"LEFT JOIN tblPayment ON tblTestInvoice.NameID =
tblPayment.PaymentID " & _
"WHERE BudgetCategory = 'Community Station' " & _
"AND tblPayment.Amount >0 " & _
"AND tblTextInvoice.BillingCyle = 'q' OR
tblTextInvoice.BillingCycle= 'm' " & _
"ELSE SELECT tblTextInvoice.*, tblPayment.Amount"
& _
"FROM tblTestInvoice " & _
"LEFT JOIN tblPayment ON tblTestInvoice.NameID =
tblPayment.PaymentID " & _
"WHERE BudgetCategory = 'Community Station' " & _
"AND tblPayment.Amount >0 " & _
"AND tblTextInvoice.BillingCycle= 'm') " & _
"ORDER BY BillCycle")
Thank you if you can help out, and I'm open to an easier
way.
Lowell Moorcroft
I'm posting this in both forms programming and queries
newsgroups.
I'm trying to include invoices billed quarterly with
invoices billed monthly if the current month is right
after the end of a quarter (i.e., the number of the month
is 4,7,10, or 1 if the current month is April, July,
October or January)
I'm switching the record set on the invoice report to
reflect this, using an SQL string in the form. I pass the
SQL string from the form to the report through a variable
and that part works fine.
But I'm getting syntex error messages when introducing the
conditional phrasing into an SQL statement to choose
between including the quarterly billings or not. I suspect
it's either too complicated or I'm trying to do something
in SQL not permissible under the .OpenRecordSet method.
I'm also uncertain of the SQL code itself, but it worked
before trying to bring in the conditional code.
I'm also uncertain about extracting the month in Access
SQL.
Here's the SQL:
Set rs = db.OpenRecordset(IF DatePart('m', Date) In
('4','7','10','1') THEN " & _
"SELECT tblTestInvoice.*, tblPayment.Amount" & _
"FROM tblTestInvoice " & _
"LEFT JOIN tblPayment ON tblTestInvoice.NameID =
tblPayment.PaymentID " & _
"WHERE BudgetCategory = 'Community Station' " & _
"AND tblPayment.Amount >0 " & _
"AND tblTextInvoice.BillingCyle = 'q' OR
tblTextInvoice.BillingCycle= 'm' " & _
"ELSE SELECT tblTextInvoice.*, tblPayment.Amount"
& _
"FROM tblTestInvoice " & _
"LEFT JOIN tblPayment ON tblTestInvoice.NameID =
tblPayment.PaymentID " & _
"WHERE BudgetCategory = 'Community Station' " & _
"AND tblPayment.Amount >0 " & _
"AND tblTextInvoice.BillingCycle= 'm') " & _
"ORDER BY BillCycle")
Thank you if you can help out, and I'm open to an easier
way.
Lowell Moorcroft