parameterized INNER JOIN Query

englishkid19

Board Regular
Joined
Nov 14, 2012
Messages
89
Hi All ,
I'm trying to get users to specify the ON clause of an INNER JOIN ? I cant get the syntax right. Essentially all i want the query to do is run exactly as it does but allow the user to input the Resource Base in the ON Clause....
Code:
SELECT AGMInput.*, AnalystInput.TOB, AnalystInput.Crews,
FROM AnalystInput INNER JOIN AGMInput ON AnalystInput.ResourceBase = AGMInput.ResourceBase
WHERE AGMInput.DateAdded = AnalystInput.Date;
Code:

Please help ....
Thanks
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
I would recommend creating a Form where they can input that, and then take the input and build the SQL in VBA.
Have a look here: Building SQL in VBA
 
Upvote 0
Sorry, I didn't realize that in addition to wanting to make the JOIN field dynamic, you were having a problem with your original code.
One little easy trick you can do in these situations, is use Access Query Builder to build the query you want. When you have it working the way you like, switch to SQL View and compare the SQL code there with what you have written and look for any differences.
 
Upvote 0
Sorry, I didn't realize that in addition to wanting to make the JOIN field dynamic, you were having a problem with your original code.
One little easy trick you can do in these situations, is use Access Query Builder to build the query you want. When you have it working the way you like, switch to SQL View and compare the SQL code there with what you have written and look for any differences.

Hi all,
I have it sorted now .
Thanks
 
Upvote 0

Forum statistics

Threads
1,221,798
Messages
6,162,025
Members
451,737
Latest member
MRASHLEY

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