Usage of a field from an unrelated table in a form

S

SGangs

I would like to display a field from a selected record from an unrelated
table - table2 (not the source) in a form as a header. Since the control
source is table1 which is in no way related to table2, i'm sort of confused
as to how can i use it. Please help.

Thanks in Advance
 
A

Allen Browne

Use a DLookup() expression in the Control Source of your text box, e.g.:
=DLookup("SomeField", "Table2")

If you need to use the Criteria as well, this may help you figure it out:
Getting a value from a table: DLookup()
at:
http://allenbrowne.com/casu-07.html
 
M

Marta Rosa

I know that this worked for SGangs, but does not work for me.

What is wrong with this statement?

=DLookup("count(id)", "[tab-alunos-des]", "escalao = Nz([escalao],1)")

I am trying to use this on a source control for a text field in a form
connected to other table (not "tab-alunos-des").

The error message says that something is missing...

I can't make it to work :(

Any help will be welcomed, thanks in advance.


"Allen Browne" escreveu:
 
P

Paul Shapiro

The DCount function returns the number of records in a specified set of
records (or domain).

The syntax for the DCount function is:
DCount ( expression, domain, [criteria] )
expression is the field that you use to count the number of records.
domain is the set of records. This can be a table or a query name.
criteria is optional. It is the WHERE clause to apply to the domain.

Marta Rosa said:
I know that this worked for SGangs, but does not work for me.

What is wrong with this statement?

=DLookup("count(id)", "[tab-alunos-des]", "escalao = Nz([escalao],1)")

I am trying to use this on a source control for a text field in a form
connected to other table (not "tab-alunos-des").

The error message says that something is missing...

I can't make it to work :(

Any help will be welcomed, thanks in advance.


"Allen Browne" escreveu:
Use a DLookup() expression in the Control Source of your text box, e.g.:
=DLookup("SomeField", "Table2")

If you need to use the Criteria as well, this may help you figure it out:
Getting a value from a table: DLookup()
at:
http://allenbrowne.com/casu-07.html
 
S

Stuart McCall

Marta Rosa said:
I know that this worked for SGangs, but does not work for me.

What is wrong with this statement?

=DLookup("count(id)", "[tab-alunos-des]", "escalao = Nz([escalao],1)")
<snip>

The Nz expression must be outside the quotes:

=DLookup("count(id)", "[tab-alunos-des]", "escalao = " & Nz([escalao],1))
 

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