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

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,215,947
Messages
6,127,867
Members
449,410
Latest member
adunn_23

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