Change SQL query values in connected database

stacyg

New Member
Joined
Sep 28, 2015
Messages
15
I have a connected database that I want to be able to create a selection box on, which once filled out I can click on a button and update my connected SQL Query. This is the query and it is fairly simple. I want to be able to change the item in the where statement. Anyone ever do this? I have found online where someone did something like this but I really did not understand the process described.

select ITM.Item, ITM.Descr as 'Description', ITM.PurchPrice as 'Purchase Price', ITM.EAI, ITM.OrdQtyEOQ as 'EOQ', ITM.Buyer, IW.[QtyOnHand] as 'Quantity on Hand', ITM.InvOnOrder as 'On Order', IW.[WH] as 'Warehouse'


From SpectraData.dbo.Items as ITM
left outer join SpectraData.[live].[RV_InvItemWH] as IW on
ITM.Item = IW.Item

where ITM.item = '90947689'

Thanks everyone!
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
This is an Excel forum, so I assume you are trying to query a database from VBA. Are you using DAO or ADO? Can you post the whole procedure?
 
Upvote 0
Sorry man, DAO or ADO mean nothing to me sorry.

I created an SQL query like the one above. I then connect a SQL database to excel through "From Other Datasources", then I go to connections and change the report from a "table" to "SQL" and paste it in to the properties and I get the result of the query in excel. What I want to do is change the "item" as mentioned above through a cell entry with new item and then have a button to trigger. I am just starting to learn VBA. I am an advanced excel user but have only recently really needed to use code to automate and add advanced function. I am sure I need to run the query from VBA but I don't know how yet.

Thanks in advance for helping me out.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

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