By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,586 Members | 623 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,586 IT Pros & Developers. It's quick & easy.

Is this possible

P: n/a
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

Mar 30 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

Mar 30 '06 #2

P: n/a
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

Mar 30 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.