A
Andy
Hi,
I am having trouble setting the ControlSource of a textbox on an
unbound subform. The textbox displays #Name?.
Environment: MS Access Project (2002, SP3).
Background: The purpose of my application is to display the hierchical
structure of an organization. An initial form uses a treeview control
to display countries, cities and offices. When a user highlights a
node representing a city and clicks a 'View' button the "City Details"
form is opened. The "City Details" form is the main form in the
context of this problem and contains a subform ("subOffices") that
should display details on offices within the chosen city.
Both the main and subforms are unbound. The mainform's record source
is set during the Form_Open event and is based on the results of a
stored procedure. Within the same procedure I call a subroutine
(located in the main form's code module) to generate an ado recordset
(the results of a stored procedure returning details about offices
within the city) and bind the subform controls to fields in the
recordset.
The line of code I've been using (and fails) is:
Me.subOffices.Form.[txtCountryName].ControlSource =
rs.Fields("Country_Name").Name
Please note:
- subOffices is the name of the subform and also the name of the
subform control on the main form.
- I deliberately named the textbox differently to the associated field
name to avoid ambiguity.
- The "Country_Name" field does exist and the recordset contains at
least one record.
- I can read the tag value of the textbox correctly with:
Debug.Print Me.subOffices.Form.Controls("txtCountryName").Tag
Can anyone please suggest what I'm doing wrong?
[Ideally I would have liked to generate the recordset for the subform
in its Open_Form event (so it works in the same way as the main form)
but that doesn't seem possible.]
Many thanks in advance,
Andy
I am having trouble setting the ControlSource of a textbox on an
unbound subform. The textbox displays #Name?.
Environment: MS Access Project (2002, SP3).
Background: The purpose of my application is to display the hierchical
structure of an organization. An initial form uses a treeview control
to display countries, cities and offices. When a user highlights a
node representing a city and clicks a 'View' button the "City Details"
form is opened. The "City Details" form is the main form in the
context of this problem and contains a subform ("subOffices") that
should display details on offices within the chosen city.
Both the main and subforms are unbound. The mainform's record source
is set during the Form_Open event and is based on the results of a
stored procedure. Within the same procedure I call a subroutine
(located in the main form's code module) to generate an ado recordset
(the results of a stored procedure returning details about offices
within the city) and bind the subform controls to fields in the
recordset.
The line of code I've been using (and fails) is:
Me.subOffices.Form.[txtCountryName].ControlSource =
rs.Fields("Country_Name").Name
Please note:
- subOffices is the name of the subform and also the name of the
subform control on the main form.
- I deliberately named the textbox differently to the associated field
name to avoid ambiguity.
- The "Country_Name" field does exist and the recordset contains at
least one record.
- I can read the tag value of the textbox correctly with:
Debug.Print Me.subOffices.Form.Controls("txtCountryName").Tag
Can anyone please suggest what I'm doing wrong?
[Ideally I would have liked to generate the recordset for the subform
in its Open_Form event (so it works in the same way as the main form)
but that doesn't seem possible.]
Many thanks in advance,
Andy