listbox equivalent

J

john

Hi all,

in a table i have a descrition code and a description
i.e.
1-a long chain of char
2-a second long chain of char
3-...

on a form i display a table with a descritpion code field
In the field i have the value 1 but i want the first description
display on the form

How can i do that? Actually i am using a listbox to display it
But it is not looking good. I want a plain text box to display it.
(The user should not change it)

I could have put the description in the table directly
but i want to save space and make it easier to maintain.

What is the common practice for that? Am i oblige to make a fucntion in
the form to perform a look up of some kind?

Regards,
John
 
R

Rick Brandt

john said:
Hi all,

in a table i have a descrition code and a description
i.e.
1-a long chain of char
2-a second long chain of char
3-...

on a form i display a table with a descritpion code field
In the field i have the value 1 but i want the first description
display on the form

How can i do that? Actually i am using a listbox to display it
But it is not looking good. I want a plain text box to display it.
(The user should not change it)

I could have put the description in the table directly
but i want to save space and make it easier to maintain.

What is the common practice for that? Am i oblige to make a fucntion
in the form to perform a look up of some kind?

Regards,
John

You could use a ComboBox. It would have two columns in its RowSource; a hidden
one that contains the number (this is the bound column), and a displayed one
that is the description. The ComboBox wizard would create this setup for you by
default.

If you HAD to use a TextBox you could use DLookup() function in its
ControlSource...

=DLookup("Description1", "TableName", "DescriptionCode = " & [DescriptionCode])
 
J

john

Hi,

Is there a way to hide the scroll bar on a combo box?

Regards,
John



Rick said:
john said:
Hi all,

in a table i have a descrition code and a description
i.e.
1-a long chain of char
2-a second long chain of char
3-...

on a form i display a table with a descritpion code field
In the field i have the value 1 but i want the first description
display on the form

How can i do that? Actually i am using a listbox to display it
But it is not looking good. I want a plain text box to display it.
(The user should not change it)

I could have put the description in the table directly
but i want to save space and make it easier to maintain.

What is the common practice for that? Am i oblige to make a fucntion
in the form to perform a look up of some kind?

Regards,
John


You could use a ComboBox. It would have two columns in its RowSource; a hidden
one that contains the number (this is the bound column), and a displayed one
that is the description. The ComboBox wizard would create this setup for you by
default.

If you HAD to use a TextBox you could use DLookup() function in its
ControlSource...

=DLookup("Description1", "TableName", "DescriptionCode = " & [DescriptionCode])
 
R

Rick Brandt

john said:
Hi,

Is there a way to hide the scroll bar on a combo box?

If you set Enabled = No and Locked = Yes then the ComboBox will not be able to
have focus, but will still have a normal appearance. Then you can create a
small rectagle the same color as your form's background and position that so it
covers the drop-arrow of the ComboBox. This will make it look like a TextBox.

The reason you have to prevent focus is that the control with focus always moves
to the top of the Z-Order on the form. This would move it in front of the
rectangle and the drop-arrow would again be visible.

Another option is to make the ComboBox hidden and then use a TextBox with a
ControlSource of...

=ComboBoxName.Colum(n)

....where 'n' is the column number that you want to see from the ComboBox (column
numbers start at zero).
 
T

Tim Ferguson

on a form i display a table with a descritpion code field
In the field i have the value 1 but i want the first description
display on the form
(The user should not change it)

Since it's read-only, you have a number of choices:

1) base the form on a query that includes a join on the table that holds
the description, and place the description in a disabled, locked text
box;

2) use a textbox and set its controlsource to DLookup() function that
will get the description value from the table

3) use the OnCurrent event to read the appropriate value from the table
and poke it into a text box. This is functionally equivalent to (2) but
allows you to do extra stuff with null values, formatting etc as desired.

In most cases I'd go for (1) because it's the "database-ish" thing to do.
Messing with the User Interface to get round what essentially a data
modelling issue is a bit second-best, IMV.


Hope that helps


Tim F
 

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