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 / Forms / May 2008

Tip: Looking for answers? Try searching our database.

Facing problems in binding Control Source

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Public - 26 May 2008 07:30 GMT
Hi,
I am facing some problems in binding the control source of a textbox to a
query that is NOT in the record set of Form (I don't want to change the
record set query). I want to show the course name when a user selects a
course ID

What I did is as follows:
1) I Created a query that have something like CourseID and CoruseName (I
called it like Courses)
2) CourseID in the query is coming from the same form that have the textbox
3) I went to the form and bound the textbox for the course name like this
[Courses]![CourseName]

And I am only seeing #Name?

Moreover, I am not sure whether this is helpful or not, but I am using MS
Access 2003.

Regards
Jeanette Cunningham - 26 May 2008 08:12 GMT
Public,
use DLookup, see vba help on DLookup.

Me.TheTextBoxName  = DLookup("[CourseName]", "qryCourse", "[CourseID] = " &
Me![CourseID]")

Assuming that you have a query called qryCourse with the CourseID and the
CourseName in it. If not, create the query.
Do not put any criteria in the criteria row of the query.

Jeanette Cunningham -- Melbourne Victoria Australia

> Hi,
> I am facing some problems in binding the control source of a textbox to a
[quoted text clipped - 16 lines]
>
> Regards
Rob Parker - 26 May 2008 08:14 GMT
You can't have more than one recordsource for bound fields on a form.

There are a couple of ways that you could get what you want, however, since
it seems that CourseID is in the current recordsource (if it's not, there is
no way you can show the related coursename).

One: add the table (or query) which contains the CourseID and CourseName
fields to your existing query which is the form's recordsource; join on the
CourseID field, set the join properties to "show all records from (existing
table in query) and only matching records from (new Courses table/query in
query)" -this will allow existing records to be shown if CourseID or
CourseName is missing.  Then bind your textbox to the CourseName field which
is now available in the form's recordsource query.

Two: use a dLookup expression in the textbox, including a criteria clause to
return the CourseName for the CourseID field of the current record; it will
be an expression similar to:
   =dLookup("CourseName","Courses","CourseID = " & [CourseID])
If CourseID is a text field, rather than a numeric field, you will need
delimiters:
   =dLookup("CourseName","Courses","CourseID = '" & [CourseID] & "'")
Expanded for clarity, that's:
   =dLookup("CourseName","Courses","CourseID = ' " & [CourseID] & " ' ")

HTH,

Rob

> Hi,
> I am facing some problems in binding the control source of a textbox
[quoted text clipped - 15 lines]
>
> Regards
Public - 26 May 2008 08:36 GMT
Thanks for your help. I t worked.
One more thing: If I want to make the criteria come from more than one
source, how would I write it? (for example, if I want the criteria to be
CourseID AND SectionID)

Regards

> You can't have more than one recordsource for bound fields on a form.
>
[quoted text clipped - 43 lines]
> >
> > Regards
Rob Parker - 26 May 2008 09:43 GMT
I assume that your referring to the dLookup method, and that you have a
SectionID field in the table/query where the CourseName is coming from; also
that SectionID is in the current form's recordsource.  The syntax will be:
    =dLookup("CourseName","Courses","CourseID = " & [CourseID] & " AND
SectionID = " & [SectionID])

Again, if the ID is a text field, you'll need single-quote delimiters as I
showed previously.

HTH,

Rob

> Thanks for your help. I t worked.
> One more thing: If I want to make the criteria come from more than one
[quoted text clipped - 52 lines]
>>>
>>> Regards
Public - 26 May 2008 13:54 GMT
Thank you guys!
It solved the problem.
However, I faced another problem now, The value that I want to show is a
hyperlink (like link to the content of that course). I have made sure that
the text box's property of is Hyperlink is "Yes". Howerver, it shows me
something like
#[MyCourseName]#. Why these additional '#' are showing up?

Regards

> I assume that your referring to the dLookup method, and that you have a
> SectionID field in the table/query where the CourseName is coming from; also
[quoted text clipped - 65 lines]
> >>>
> >>> Regards
Jeanette Cunningham - 27 May 2008 00:53 GMT
have a look at:
The PrepareHyperlink() function can also be used to massage a file name so
it will be handled correctly as a hyperlink.

On this site
http://www.allenbrowne.com/func-GoHyperlink.html

Jeanette Cunningham -- Melbourne Victoria Australia

> Thank you guys!
> It solved the problem.
[quoted text clipped - 78 lines]
>> >>>
>> >>> Regards
 
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.