Caption

B

Bob Betts

How do i make a caption of a form equal to a field in a table...

example Tablename : tblCOMPANY
Field : co_name

on the on load event of a form do i put a code like

me.caption=
![tblCOMPANY]![co_name] .....
 
N

Nikos Yannacopoulos

Bob.

What you need is a DLookup function:

Me.Caption = DLookup("co_name","tblCOMPANY","co_ID=" & Me.txtCo_ID )

where I have assumed there is a txtCo_ID control on the form, holding
the companyID, which is stored in field co_ID in the table.

HTH,
Nikos
 
N

Nikos Yannacopoulos

Oops... forgot to say that will only work with a numeric co_ID; in case
it is text, the expression should be:

Me.Caption = DLookup("co_name", "tblCOMPANY", "co_ID='" & Me.tctCo_ID & "'")

(in one line, in case it gets wrapped in your newsreader!).
 
B

Bob Betts

Thanks Nikos.. will try it out...
Nikos Yannacopoulos said:
Oops... forgot to say that will only work with a numeric co_ID; in case
it is text, the expression should be:

Me.Caption = DLookup("co_name", "tblCOMPANY", "co_ID='" & Me.tctCo_ID & "'")

(in one line, in case it gets wrapped in your newsreader!).

Bob said:
How do i make a caption of a form equal to a field in a table...

example Tablename : tblCOMPANY
Field : co_name

on the on load event of a form do i put a code like

me.caption=
![tblCOMPANY]![co_name] .....
 
B

Bob Betts

by the way... what's the co-id for... i have only two fields.. name and
address..
Nikos Yannacopoulos said:
Oops... forgot to say that will only work with a numeric co_ID; in case
it is text, the expression should be:

Me.Caption = DLookup("co_name", "tblCOMPANY", "co_ID='" & Me.tctCo_ID & "'")

(in one line, in case it gets wrapped in your newsreader!).

Bob said:
How do i make a caption of a form equal to a field in a table...

example Tablename : tblCOMPANY
Field : co_name

on the on load event of a form do i put a code like

me.caption=
![tblCOMPANY]![co_name] .....
 
N

Nikos Yannacopoulos

Bob,

Like I said in my original answer, I assumed co_ID to be the PK field in
tblCOMPANY. It's probably called something else, just substitute the
actual field name.

Nikos

Bob said:
by the way... what's the co-id for... i have only two fields.. name and
address..
Oops... forgot to say that will only work with a numeric co_ID; in case
it is text, the expression should be:

Me.Caption = DLookup("co_name", "tblCOMPANY", "co_ID='" & Me.tctCo_ID &
"'")

(in one line, in case it gets wrapped in your newsreader!).

Bob said:
How do i make a caption of a form equal to a field in a table...

example Tablename : tblCOMPANY
Field : co_name

on the on load event of a form do i put a code like

me.caption=
![tblCOMPANY]![co_name] .....
 

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