Insert parameters directly into SQL query

markspraggins

New Member
Joined
Mar 28, 2008
Messages
7
I have the following SQL query:

SELECT "TransHeaders"."Logged", "Branches"."Name", "Departments"."Description", "TransLines"."Quantity", "TransLines"."SubBeforeTax", "TransLines"."SubAfterTax", "TransLines"."TransNo", "TransHeaders"."TransStatus"
FROM ((("AKPOS"."dbo"."TransLines" "TransLines" LEFT OUTER JOIN "AKPOS"."dbo"."TransHeaders" "TransHeaders" ON (("TransLines"."TransNo"="TransHeaders"."TransNo") AND ("TransLines"."Branch"="TransHeaders"."Branch")) AND ("TransLines"."Station"="TransHeaders"."Station")) LEFT OUTER JOIN "AKPOS"."dbo"."Branches" "Branches" ON "TransLines"."Branch"="Branches"."ID") LEFT OUTER JOIN "AKPOS"."dbo"."Items" "Items" ON "TransLines"."UPC"="Items"."UPC") LEFT OUTER JOIN "AKPOS"."dbo"."Departments" "Departments" ON "Items"."Department"="Departments"."ID"
WHERE "TransHeaders"."TransStatus"<>'V' AND ("TransHeaders"."Logged">={ts '2011-01-01 00:00:00'} AND "TransHeaders"."Logged"<{ts '2011-01-16 00:00:00'})
ORDER BY "Branches"."Name", "Departments"."Description"

where the date fields (in red) need to vary. I want to reference to cells B1 and B3 on a worksheet called "dates" which I can then change to suit.

I am only used to using the graphical interface so would appreciate help!

Thanks
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,216,804
Messages
6,132,797
Members
449,760
Latest member
letonuslepus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top