Retrieve the Control Source of a Text box in an Acess form

A

Aldo

Hi guys,

I have a Form (Access 2007) that is based on a query named "PeopleSex".
The query is based on two tables: "Peoples" and "Sex".
On the form named "PeopleSex" (as the query), I have a Text Box named
"FirstName".
The text box "FirstName" is bound to the table "People".

What I need is to programmatically retrieve the name of the that table
"People" from the Text box properties.
I tried using ControlSource, but I am missing something...

Thanks in advance for any help,
Aldo.
 
D

Dirk Goldgar

Aldo said:
Hi guys,

I have a Form (Access 2007) that is based on a query named "PeopleSex".
The query is based on two tables: "Peoples" and "Sex".
On the form named "PeopleSex" (as the query), I have a Text Box named
"FirstName".
The text box "FirstName" is bound to the table "People".

What I need is to programmatically retrieve the name of the that table
"People" from the Text box properties.
I tried using ControlSource, but I am missing something...


It seems to me that what you want is the SourceTable property of the field
to which the control is bound. If the form is open, you can get this like
this:

Dim strSourceTable As String

With Forms!PeopleSex
strSourceTable =
.Recordset.Fields(.Controls("FirstName").ControlSource).SourceTable
End With

Note that the form must be open for this to work.
 
A

Aldo

Thank you man!


Dirk Goldgar said:
It seems to me that what you want is the SourceTable property of the field
to which the control is bound. If the form is open, you can get this like
this:

Dim strSourceTable As String

With Forms!PeopleSex
strSourceTable =
.Recordset.Fields(.Controls("FirstName").ControlSource).SourceTable
End With

Note that the form must be open for this to work.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top