Close to what?
You've told us how you expect, perhaps, to accomplish something, but you
haven't told us what it is you are trying to accomplish.
You can use the InStr function to determine if the exact string used in
ControlSource exists in the particular Query. You cannot do it with the code
you show.
You would need to explain what you are trying to accomplish with "Wherestr".
Or, even, just what you expect it will contain if, say, the control source
is "SomeFieldName". Control Source may be an expression if the Control is a
Calculated Control, or the name of a Field in the Record Source. Normally,
"name of a Field" means just that, and would not include a Table name. There
may be some cases, for example, where there are Fields of the same name in
multiple Tables, in which case a Table name might be used to qualify it.
That doesn't happen in my databases, because I will avoid duplication in the
Query, by using an Alias.
Larry Linson
Microsoft Access MVP
<Wo********@hotmail.com> wrote in message
news:11**********************@e56g2000cwe.googlegr oups.com...
Can someone tell me if this is close and if it can be done
IF ctl.control Source in CurrentDb.Querydefs("Maps and Plans Query")
then
Wherestr = Wherestr & "(((" & "[Table_name].[colum name]" & ")" & "="
& "" " & ctl.Control Source & "" " & ")"
What i'm trying to do is to get it to check to see if the text writin
in ctl.control Source is in the Maps and Plans Query somewhere then if
it is then i would like it to write it to the string called wherestr.
Thanks Nathan