Taking value and using it to search tables

W

Woodies_46

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
 
D

Douglas J Steele

What you've got definitely has some syntactical errors in it.

For one thing, the name of the property is ControlSource (no space), and you
cannot use In in the manner you're trying.

And while it's not the cause of problems, your where string is more
complicated than necessary: while Access may put all those parentheses,
they're not required:

Wherestr = Wherestr & "([Table_name].[colum name])=""" & _
ctl.ControlSource & """)"

Note, too, that you're putting a space before and after what's in
ctl.ControlSource in what you have.

Can you give an example of what you're looking for?
 
Top