Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / March 2006

Tip: Looking for answers? Try searching our database.

Is this possible

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Woodies_46@hotmail.com - 30 Mar 2006 02:22 GMT
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
chris.nebinger@gmail.com - 30 Mar 2006 15:39 GMT
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
Larry Linson - 30 Mar 2006 18:17 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.