Show value in text box automatically

G

Guest

Hi,

I hope someone can help with this! It seems like it should be so simple, but
for some reason my brain is drawing a blank today!

I am having trouble with a text box on my form. There are 2 forms: Clients,
and Documents. They are linked through ClientID, which is the foreign key in
the Documents Table. From the Clients Form, there is a button that opens the
Documents Form, and the corresponding ClientID shows up in the text box, so
they are linking correctly. However, I want the Client's name to show up
instead of the ID number. I've done this about a hundred times in a
combo/Lookup box, but I can't figure it out in a text box! I know I need to
somehow get the name values from the Contacts Table, but how?

Thanks!
Rose.
 
B

Brian Bastl

for hopefully obvious reasons, the text box displaying the client's id
should remain that way, unless you change it to a combo control. Hide it if
you wish. What you can do is overlay it with an unbound textbox which could
show the client's name via DLookUp().

HTH,
Brian
 
B

Brian Bastl

Rose,

You should really try to familiarize yourself with these basic functions. If
ever unsure of your syntax, click on the function name and press the F1 key
to bring up the appropriate help file. There will usually be a fairly decent
explanation and associated example.

for the sake of this example, let's name the text box displaying the
ClientID as txtClientID on your Documents form (aka frmDocuments), and your
new unbound text box as txtClientName. With the form open in design view,
dbl-click your new unbound text box to bring up its propery sheet. Click the
"All" tab. Next click on the words "Control Source". To the far right will
be a button with three dots [...]. Click this to launch the Expression
Builder.

The syntax for DLookUp() in your case is:

=DLookUp("[Field Name In Lookup Table]", "[Name of Lookup Table]",
"[Identifying Field in Lookup Table]=" & [Criteria])

the expression you type should look like the following, substituting the
names in the example with those in your database:

=DLookUp("ClientName","tblClients","[ClientID]=" &
[Forms]![frmDocuments]![txtClientID])

HTH,
Brian
 
G

Guest

Thanks Brian!

It is working (mostly)! The only problem is I can only get it to work with
EITHER the First or Last name, but not both. How do I concantenate the name
fields in this kind of expression?
Here is my expression:
=DLookUp("First","Contacts","[ClientID]=" & Forms!Documents!ClientID)

Thanks so much!
Rose.

Brian Bastl said:
Rose,

You should really try to familiarize yourself with these basic functions. If
ever unsure of your syntax, click on the function name and press the F1 key
to bring up the appropriate help file. There will usually be a fairly decent
explanation and associated example.

for the sake of this example, let's name the text box displaying the
ClientID as txtClientID on your Documents form (aka frmDocuments), and your
new unbound text box as txtClientName. With the form open in design view,
dbl-click your new unbound text box to bring up its propery sheet. Click the
"All" tab. Next click on the words "Control Source". To the far right will
be a button with three dots [...]. Click this to launch the Expression
Builder.

The syntax for DLookUp() in your case is:

=DLookUp("[Field Name In Lookup Table]", "[Name of Lookup Table]",
"[Identifying Field in Lookup Table]=" & [Criteria])

the expression you type should look like the following, substituting the
names in the example with those in your database:

=DLookUp("ClientName","tblClients","[ClientID]=" &
[Forms]![frmDocuments]![txtClientID])

HTH,
Brian


Rose H. said:
Thanks Brian!

How do I do a DLookUp?

TIA,
Rose.
 
B

Brian Bastl

Rose,

I suppose my first response was slightly incomplete, at best. The way I
initially described is just one way. Using an overlaying text box probably
wasn't the best suggestion, however. Changing the textbox, which displays
the ClientID, to a combobox would be a much better option IMHO.

Do you agree?

Brian


Rose H. said:
Thanks Brian!

It is working (mostly)! The only problem is I can only get it to work with
EITHER the First or Last name, but not both. How do I concantenate the name
fields in this kind of expression?
Here is my expression:
=DLookUp("First","Contacts","[ClientID]=" & Forms!Documents!ClientID)

Thanks so much!
Rose.

Brian Bastl said:
Rose,

You should really try to familiarize yourself with these basic functions. If
ever unsure of your syntax, click on the function name and press the F1 key
to bring up the appropriate help file. There will usually be a fairly decent
explanation and associated example.

for the sake of this example, let's name the text box displaying the
ClientID as txtClientID on your Documents form (aka frmDocuments), and your
new unbound text box as txtClientName. With the form open in design view,
dbl-click your new unbound text box to bring up its propery sheet. Click the
"All" tab. Next click on the words "Control Source". To the far right will
be a button with three dots [...]. Click this to launch the Expression
Builder.

The syntax for DLookUp() in your case is:

=DLookUp("[Field Name In Lookup Table]", "[Name of Lookup Table]",
"[Identifying Field in Lookup Table]=" & [Criteria])

the expression you type should look like the following, substituting the
names in the example with those in your database:

=DLookUp("ClientName","tblClients","[ClientID]=" &
[Forms]![frmDocuments]![txtClientID])

HTH,
Brian


Rose H. said:
Thanks Brian!

How do I do a DLookUp?

TIA,
Rose.

:

for hopefully obvious reasons, the text box displaying the client's id
should remain that way, unless you change it to a combo control.
Hide it
if
you wish. What you can do is overlay it with an unbound textbox
which
could
show the client's name via DLookUp().

HTH,
Brian


Hi,

I hope someone can help with this! It seems like it should be so simple,
but
for some reason my brain is drawing a blank today!

I am having trouble with a text box on my form. There are 2 forms:
Clients,
and Documents. They are linked through ClientID, which is the
foreign
key
in
the Documents Table. From the Clients Form, there is a button that opens
the
Documents Form, and the corresponding ClientID shows up in the
text
box,
so
they are linking correctly. However, I want the Client's name to
show
up
instead of the ID number. I've done this about a hundred times in a
combo/Lookup box, but I can't figure it out in a text box! I know
I
need
to
somehow get the name values from the Contacts Table, but how?

Thanks!
Rose.
 
J

John Spencer

You can use the following to get the First and Last Names together. The pairs
of quotes are needed to return the space.

=DLookUp("First & "" "" & Last","Contacts","[ClientID]=" & Forms!Documents!ClientID)
Thanks Brian!

It is working (mostly)! The only problem is I can only get it to work with
EITHER the First or Last name, but not both. How do I concantenate the name
fields in this kind of expression?
Here is my expression:
=DLookUp("First","Contacts","[ClientID]=" & Forms!Documents!ClientID)

Thanks so much!
Rose.

Brian Bastl said:
Rose,

You should really try to familiarize yourself with these basic functions. If
ever unsure of your syntax, click on the function name and press the F1 key
to bring up the appropriate help file. There will usually be a fairly decent
explanation and associated example.

for the sake of this example, let's name the text box displaying the
ClientID as txtClientID on your Documents form (aka frmDocuments), and your
new unbound text box as txtClientName. With the form open in design view,
dbl-click your new unbound text box to bring up its propery sheet. Click the
"All" tab. Next click on the words "Control Source". To the far right will
be a button with three dots [...]. Click this to launch the Expression
Builder.

The syntax for DLookUp() in your case is:

=DLookUp("[Field Name In Lookup Table]", "[Name of Lookup Table]",
"[Identifying Field in Lookup Table]=" & [Criteria])

the expression you type should look like the following, substituting the
names in the example with those in your database:

=DLookUp("ClientName","tblClients","[ClientID]=" &
[Forms]![frmDocuments]![txtClientID])

HTH,
Brian


Rose H. said:
Thanks Brian!

How do I do a DLookUp?

TIA,
Rose.

:

for hopefully obvious reasons, the text box displaying the client's id
should remain that way, unless you change it to a combo control. Hide it if
you wish. What you can do is overlay it with an unbound textbox which could
show the client's name via DLookUp().

HTH,
Brian


Hi,

I hope someone can help with this! It seems like it should be so simple,
but
for some reason my brain is drawing a blank today!

I am having trouble with a text box on my form. There are 2 forms:
Clients,
and Documents. They are linked through ClientID, which is the foreign key
in
the Documents Table. From the Clients Form, there is a button that opens
the
Documents Form, and the corresponding ClientID shows up in the text box,
so
they are linking correctly. However, I want the Client's name to show up
instead of the ID number. I've done this about a hundred times in a
combo/Lookup box, but I can't figure it out in a text box! I know I need
to
somehow get the name values from the Contacts Table, but how?

Thanks!
Rose.
 
G

Guest

Thank you soooo much! It works perfectly!
I appreciate your help!
Rose.

John Spencer said:
You can use the following to get the First and Last Names together. The pairs
of quotes are needed to return the space.

=DLookUp("First & "" "" & Last","Contacts","[ClientID]=" & Forms!Documents!ClientID)
Thanks Brian!

It is working (mostly)! The only problem is I can only get it to work with
EITHER the First or Last name, but not both. How do I concantenate the name
fields in this kind of expression?
Here is my expression:
=DLookUp("First","Contacts","[ClientID]=" & Forms!Documents!ClientID)

Thanks so much!
Rose.

Brian Bastl said:
Rose,

You should really try to familiarize yourself with these basic functions. If
ever unsure of your syntax, click on the function name and press the F1 key
to bring up the appropriate help file. There will usually be a fairly decent
explanation and associated example.

for the sake of this example, let's name the text box displaying the
ClientID as txtClientID on your Documents form (aka frmDocuments), and your
new unbound text box as txtClientName. With the form open in design view,
dbl-click your new unbound text box to bring up its propery sheet. Click the
"All" tab. Next click on the words "Control Source". To the far right will
be a button with three dots [...]. Click this to launch the Expression
Builder.

The syntax for DLookUp() in your case is:

=DLookUp("[Field Name In Lookup Table]", "[Name of Lookup Table]",
"[Identifying Field in Lookup Table]=" & [Criteria])

the expression you type should look like the following, substituting the
names in the example with those in your database:

=DLookUp("ClientName","tblClients","[ClientID]=" &
[Forms]![frmDocuments]![txtClientID])

HTH,
Brian


Thanks Brian!

How do I do a DLookUp?

TIA,
Rose.

:

for hopefully obvious reasons, the text box displaying the client's id
should remain that way, unless you change it to a combo control. Hide it
if
you wish. What you can do is overlay it with an unbound textbox which
could
show the client's name via DLookUp().

HTH,
Brian


Hi,

I hope someone can help with this! It seems like it should be so
simple,
but
for some reason my brain is drawing a blank today!

I am having trouble with a text box on my form. There are 2 forms:
Clients,
and Documents. They are linked through ClientID, which is the foreign
key
in
the Documents Table. From the Clients Form, there is a button that
opens
the
Documents Form, and the corresponding ClientID shows up in the text
box,
so
they are linking correctly. However, I want the Client's name to show
up
instead of the ID number. I've done this about a hundred times in a
combo/Lookup box, but I can't figure it out in a text box! I know I
need
to
somehow get the name values from the Contacts Table, but how?

Thanks!
Rose.
 

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