I'm not sure I understand what you're asking. ctl.ControlSource should
return the name of the field that the control is bound to. Are you
asking if that field exists in the "Maps and Plans Query"? If so:
Public Function FieldExists(strQueryName as String, strFieldName as
String) as Boolean
Dim dbs as DAO.Database
Dim rst as DAO.Recordset
Dim fld as DAO.Field
Set dbs = CurrentDB
Set rst = dbs.OpenRecordset(strQueryName)
For Each fld In rst.Fields
If fld.Name = strFieldName then
FieldExists = True
Exit Function
End If
Next fld
FieldExists = False
End Function
Chris Nebinger
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
> Can someone tell me if this is close and if it can be done
>
[quoted text clipped - 8 lines]
>
> Thanks Nathan