Text box contents in a form

  • Thread starter Thread starter simonc
  • Start date Start date
S

simonc

I am designing a form to input data to a table. In one
combo box I can select a number from the Primary key field
of a different table. In another text box I want to
display automatically a text field from the other table
which corresponds to the primary key number. All my
attempts at putting in an expression for the Control
Source of this text box result in the box displaying
#Name?

What is the correct syntax?

Attempts:

= SELECT «Expr» [Shareholders]![Shareholder] WHERE «Expr»
[Shareholders]![Share certificate no] = [Share Certificate
no]

= (SELECT «Expr» [Shareholders]![Shareholder] WHERE «Expr»
[Shareholders]![Share certificate no] = [Share Certificate
no])
 
Many thanks for this help. I don't know who you all are -
the people who take time to answer queries on these
message boards - but I am extremely grateful for your
input.

Many thanks again
-----Original Message-----
Use a DLookUp in the AfterUpdate event for the ComboBox.
This assumes your form has a ComboBox listing the
certificate numbers (cboCertNumber) and a TextBox for the
shareholder name (txtShareHolder).

' declare variables
Dim strCertificate as String (or appropriate data type)
Dim strShareHolder as String

strCertificate = [cboCertNumber]

' look up shareholder name
strShareHolder = DLookUp("[ShareHolder]", _
"ShareHolders", "[Share Certificate No] = '" _
& strCertificate & "'")

' populate shareholder name
[txtShareHolder] = strShareHolder

Check the Help files for details on DLookUps They're
very, very handy and I use them a lot.

Hope this helps!

Howard Brody



-----Original Message-----
I am designing a form to input data to a table. In one
combo box I can select a number from the Primary key field
of a different table. In another text box I want to
display automatically a text field from the other table
which corresponds to the primary key number. All my
attempts at putting in an expression for the Control
Source of this text box result in the box displaying
#Name?

What is the correct syntax?

Attempts:

= SELECT «Expr» [Shareholders]![Shareholder] WHERE «Expr»
[Shareholders]![Share certificate no] = [Share Certificate
no]

= (SELECT «Expr» [Shareholders]![Shareholder] WHERE «Expr»
[Shareholders]![Share certificate no] = [Share Certificate
no])

.
.
 
Back
Top