Textbox Control Source

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form that contains fields from 1 table, tblData
I want a textbox on that form,txtRandomPoints, to be controlled by a field on another table, tblPoints.PointsEarned
How do I do that

RIP
 
What do you mean, "controlled"? If you want it to show a related value,
you need to base the form on a query that includes that field - this is
the simplest and most common way. If you want something else, you need
to address that table in VBA code for the form. This is more technical
and you should resort to this only if your needs are not answered by
using the query containing the foreign field.

Pavel
 
You can base the textbox on data from another table in several ways:

1. By using VBA code in the form's Current event to populate the control.
Me.txtMyTextBox = Nz(DLookup("[somefield]", "tblSomeTable", "some
criteria"), "")

2. By "binding" the textbox to another table's field, by adding the
following to the textbox's ControlSource property:
=Nz(DLookup("[somefield]", "tblSomeTable", "some criteria"), "")

With both options, the data is refreshed every time you move to a different
record. With option 2, the data is not updatable, because the control is
"bound" to the DLookup value.

3. You can include the other table's field in a query on which you can base
the form, and bind the textbox in the usual way.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html


Ripper said:
I have a form that contains fields from 1 table, tblData.
I want a textbox on that form,txtRandomPoints, to be controlled by a field
on another table, tblPoints.PointsEarned.
 
Back
Top