Text box data

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I have a table with an id and count field that is linked
to my main table(One -> one relationship). I have one
form which I show info from the main table but I also want
to use the count field in the same form. I add the text
box and in the control source property I use
=[TableName]![count] but get #Name in the text box
instead of the data. Any ideas?
 
You cannot reference a table using the syntax that you tried. There are two
ways you can do what you want, though.

One:
You need to use a query as the recordsource for the form, and the query
needs to include both tables in its design. Be sure that you have the count
field (by the way, not a good idea to use count, or to use name, date, time,
month, year, path, etc., as field or control names, because these are
reserved words - meaning that they are the names of functions or properties
or methods in ACCESS and you can greatly confuse ACCESS if you ever forget
to use the [ ] characters to delimit the names) in the query's field list.
Then change the control source to this:
=[count]

Two:
You can use the DLookup function in the control source expression to look up
the value of count from the table:
=DLookup("count", "TableName", "PrimaryKeyFieldName = " &
[FieldNameFromFormRecordsource)

Post back with more info about which option you think will work best for
you, and we'll help you correctly write the expression .
 
-----Original Message-----
You cannot reference a table using the syntax that you tried. There are two
ways you can do what you want, though.

One:
You need to use a query as the recordsource for the form, and the query
needs to include both tables in its design. Be sure that you have the count
field (by the way, not a good idea to use count, or to use name, date, time,
month, year, path, etc., as field or control names, because these are
reserved words - meaning that they are the names of functions or properties
or methods in ACCESS and you can greatly confuse ACCESS if you ever forget
to use the [ ] characters to delimit the names) in the query's field list.
Then change the control source to this:
=[count]

Two:
You can use the DLookup function in the control source expression to look up
the value of count from the table:
=DLookup
("count", "TableName", "PrimaryKeyFieldName = " &
[FieldNameFromFormRecordsource)

Post back with more info about which option you think will work best for
you, and we'll help you correctly write the expression .

--
Ken Snell
<MS ACCESS MVP>

I have a table with an id and count field that is linked
to my main table(One -> one relationship). I have one
form which I show info from the main table but I also want
to use the count field in the same form. I add the text
box and in the control source property I use
=[TableName]![count] but get #Name in the text box
instead of the data. Any ideas?


.
Thanks, I thought about the query and probably the best
idea since I need to have the ability to enter dats into
it.
 
Back
Top