Displaying a memo in a text box based on the selection in a list b

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In a form I have a list box "lstDMList" and a text box "txtDesc". The entries
in the list box come from a query "qryListName" that references the contents
of a text column "DMName" in a table "Database". Also in the table "Database"
is a memo column "memDesc" (memo-type because it can contain up to 500
characters, so a text-type column is insufficient).

When I select an entry in the list box "lstDMList" I want the text box to
display the contents of the appropriate row in the "memDesc" column. How
would I go about doing this? I know effectively nothing about the programming
and Visual Basic, so an easy-to-follow explanation would be greatly welcome.
I use Office 2000.


Thanks in advance,
~Maruno
 
well, you don't need to use VBA, just a fairly simple expression in your
textbox control. first, make sure that the query, used as the RowSource of
the listbox, includes the primary key field of the Database table. it's
usually easiest just to use that field as the BoundColumn of the listbox
control (don't confuse the BoundColumn property with the ControlSource
property - read up on both topics in Access Help if you need clarification).
next, add an expression to the ControlSource property of the textbox
control, as

=IIf([ListBoxControlName] Is Null, Null, DLookUp("[MemoFieldName]",
"Database", "[PrimaryKeyFieldName] = " & [ListBoxControlName]))

the above goes all on one line in the ControlSource property, and the
expression assumes that the primary key field of table Database is the bound
column of the listbox control. read up on the DLookUp() function in Access
Help if you're not familiar with it.

btw, recommend you change the name of the "Database" table, as that's an
Access Reserved word (tblDatabase would be fine). see
http://home.att.net/~california.db/tips.html#aTip5 for more information.

hth
 
This works perfectly, albeit a little slowly (half a second, but that's
fine). Thanks very much!

~Maruno



tina said:
well, you don't need to use VBA, just a fairly simple expression in your
textbox control. first, make sure that the query, used as the RowSource of
the listbox, includes the primary key field of the Database table. it's
usually easiest just to use that field as the BoundColumn of the listbox
control (don't confuse the BoundColumn property with the ControlSource
property - read up on both topics in Access Help if you need clarification).
next, add an expression to the ControlSource property of the textbox
control, as

=IIf([ListBoxControlName] Is Null, Null, DLookUp("[MemoFieldName]",
"Database", "[PrimaryKeyFieldName] = " & [ListBoxControlName]))

the above goes all on one line in the ControlSource property, and the
expression assumes that the primary key field of table Database is the bound
column of the listbox control. read up on the DLookUp() function in Access
Help if you're not familiar with it.

btw, recommend you change the name of the "Database" table, as that's an
Access Reserved word (tblDatabase would be fine). see
http://home.att.net/~california.db/tips.html#aTip5 for more information.

hth


Maruno said:
In a form I have a list box "lstDMList" and a text box "txtDesc". The entries
in the list box come from a query "qryListName" that references the contents
of a text column "DMName" in a table "Database". Also in the table "Database"
is a memo column "memDesc" (memo-type because it can contain up to 500
characters, so a text-type column is insufficient).

When I select an entry in the list box "lstDMList" I want the text box to
display the contents of the appropriate row in the "memDesc" column. How
would I go about doing this? I know effectively nothing about the programming
and Visual Basic, so an easy-to-follow explanation would be greatly welcome.
I use Office 2000.


Thanks in advance,
~Maruno
 
you're welcome :)


Maruno said:
This works perfectly, albeit a little slowly (half a second, but that's
fine). Thanks very much!

~Maruno



tina said:
well, you don't need to use VBA, just a fairly simple expression in your
textbox control. first, make sure that the query, used as the RowSource of
the listbox, includes the primary key field of the Database table. it's
usually easiest just to use that field as the BoundColumn of the listbox
control (don't confuse the BoundColumn property with the ControlSource
property - read up on both topics in Access Help if you need clarification).
next, add an expression to the ControlSource property of the textbox
control, as

=IIf([ListBoxControlName] Is Null, Null, DLookUp("[MemoFieldName]",
"Database", "[PrimaryKeyFieldName] = " & [ListBoxControlName]))

the above goes all on one line in the ControlSource property, and the
expression assumes that the primary key field of table Database is the bound
column of the listbox control. read up on the DLookUp() function in Access
Help if you're not familiar with it.

btw, recommend you change the name of the "Database" table, as that's an
Access Reserved word (tblDatabase would be fine). see
http://home.att.net/~california.db/tips.html#aTip5 for more information.

hth


Maruno said:
In a form I have a list box "lstDMList" and a text box "txtDesc". The entries
in the list box come from a query "qryListName" that references the contents
of a text column "DMName" in a table "Database". Also in the table "Database"
is a memo column "memDesc" (memo-type because it can contain up to 500
characters, so a text-type column is insufficient).

When I select an entry in the list box "lstDMList" I want the text box to
display the contents of the appropriate row in the "memDesc" column. How
would I go about doing this? I know effectively nothing about the programming
and Visual Basic, so an easy-to-follow explanation would be greatly welcome.
I use Office 2000.


Thanks in advance,
~Maruno
 

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

Back
Top