ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   SQL Query with constraint in a cell (https://www.excelbanter.com/excel-discussion-misc-queries/223745-sql-query-constraint-cell.html)

dan

SQL Query with constraint in a cell
 
Excel 2007: I am pulling data from an external source (Data ribbon, From
Other Sources, From SQL Server) using a query:

Select * from Transactions where TransType = 'NEW'

I'd like to put the value of TransType in a cell, so I can change the value
in the workbook, <Refresh ALL, and the query runs with a different
constraint.

Is this possible? How do I pass the value of a cell to the query? I prefer
to NOT use VB, a form, or a macro.

Thanks! in advance.

--Dan


Shane Devenshire

SQL Query with constraint in a cell
 
Hi,

I don't think there is any way to do that without VBA.

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"Dan" wrote:

Excel 2007: I am pulling data from an external source (Data ribbon, From
Other Sources, From SQL Server) using a query:

Select * from Transactions where TransType = 'NEW'

I'd like to put the value of TransType in a cell, so I can change the value
in the workbook, <Refresh ALL, and the query runs with a different
constraint.

Is this possible? How do I pass the value of a cell to the query? I prefer
to NOT use VB, a form, or a macro.

Thanks! in advance.

--Dan


dan

SQL Query with constraint in a cell
 
OK. So... if I need VBA, where would I go to find an example?
The worksheet is reporting on today's transactions, dashboard-like. The
cell would contain a Julian date of the form 'nnn'.

The transactions have an eleven digit transaction number, of the form
'2009xxxyyyy', whe
xxx = The Julian date (e.g. March 10 would be '069'
yyyy = a sequential transaction number (e.g. '0001', '0002', ...)

The query would be of the form:
-----
select TransactionNumber, AgentName, TransactionTime, RequestClass,
RequestType, ...

from WorkingDatabase
where substring(TransactionType,1,7) = '2009069'
------
'069' would be in the cell. Let's say... cell A1 on Sheet1.
TransactionNumber is a text field.

Thanks for the help.

--Dan

"Shane Devenshire" wrote:

Hi,

I don't think there is any way to do that without VBA.

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"Dan" wrote:

Excel 2007: I am pulling data from an external source (Data ribbon, From
Other Sources, From SQL Server) using a query:

Select * from Transactions where TransType = 'NEW'

I'd like to put the value of TransType in a cell, so I can change the value
in the workbook, <Refresh ALL, and the query runs with a different
constraint.

Is this possible? How do I pass the value of a cell to the query? I prefer
to NOT use VB, a form, or a macro.

Thanks! in advance.

--Dan



All times are GMT +1. The time now is 02:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com