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

  • Thread starter Thread starter Aldo
  • Start date Start date
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.
 
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.
 
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)
 
Back
Top