(Msg. 1) Posted: Thu Nov 01, 2007 10:54 am
Post subject: SQL & Like and parameters Archived from groups: microsoft>public>excel>querydao (more info?)
I would like to have the operator prompted for a "like" value. For
instance, I would like the operator to be prompted to enter the word
PUSH if the description field contains PUSH anywhere in the
description.
This is a query using microsoft query which returns data to excel.
For normal parameter queries you enter in the criteria something like
[Enter value to search for]. That works on queries for "equal"
conditions, but I can't figure out how to prompt for a "Like"
condition that I want the user to be able to enter the parameter for.
For instance I think I need to enter something like:
Like "'%"[Enter value to search for]"%'" but that doesn't seem to
work. I could write this in the SQL native if someone could give me an
idea how to do that too, since the query criteria eventually gets
generated into SQL anyway.
Can anyone help me? This is a unique situation because of the LIKE
and wild-card symbols.
(Msg. 2) Posted: Fri Nov 02, 2007 5:57 pm
Post subject: Re: SQL & Like and parameters [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
I think Microsoft Query has trouble parsing that condition.
I succeeded as follows:
In the query grid I entered the condition as Like [Param]
To test it I entered %PUSH% and it worked
I returned the results to Excel and associated the parameter with a
cell, in my case E2, specifying it to refresh automatically when the
cell changes.
In E2 I entered the formula ="%"&E3&"%"
The when I entered PULL in E3 it returns results for which the field
contains "PULL" etc.
So all you need then is some suitable UI for your user to get the value
to be sought into an appropriate cell (in my case E3)
Bill Manville
MVP - Microsoft Excel, Oxford, England
All times are: Eastern Time (US & Canada) (change)
Page 1 of 1
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum