Combo or List box

G

Guest

I'm struggling with list or combo boxes and would appreciate some help or
maybe I'm looking for the wrong thing.

I have a form in which I enter several codes to create the criteria for a
report query. This works just fine.

There is an associated description for each code in other tables.

All I want to do is to display alongside the input box the associated
description of the code I've just entered.

Thanks
 
J

John W. Vinson

All I want to do is to display alongside the input box the associated
description of the code I've just entered.

Do you need to display BOTH the code and the description? Ordinarily a Combo
Box would store a code while displaying the description.

If you do want to see both, you can set the Control Source of a textbox to

=comboboxname.Column(1)

to display the second column (it's zero based) of the combo box. Set up the
combo so that it contains both the code and the description.

John W. Vinson [MVP]
 
G

Guest

Thanks for the reply, that's not quite what I'm looking for. After having
entered a code in the input box and pressed TAB/return to move on I want the
corressponding description for the entered code to be displayed in the area
adjacent to the input box having looked it up.
 
J

John W. Vinson

Thanks for the reply, that's not quite what I'm looking for. After having
entered a code in the input box and pressed TAB/return to move on I want the
corressponding description for the entered code to be displayed in the area
adjacent to the input box having looked it up.

That's exactly and precisely what my suggestion does. Did you try it?

Or are you proposing having the user type a code into a textbox (rather than
selecting from a list of valid codes), displaying the description if they
happen to get it right, and slapping their hands if they make a mistake?

John W. Vinson [MVP]
 
G

Guest

Thanks for the reply. I'm sorry about not being clear.

It is the second thing I'm trying to achieve, I did try your suggestion but
the text box only gave NAME errors.

Thanks for your patience and help
 
J

John W. Vinson

Thanks for the reply. I'm sorry about not being clear.

It is the second thing I'm trying to achieve, I did try your suggestion but
the text box only gave NAME errors.

Thanks for your patience and help

Please post:

The name of the form
The name and type (textbox? combo?) of the two controls
Their Control Source properties

John W. Vinson [MVP]
 
G

Guest

form name - frm SalesHistoryView
input control : text box
name : Start Account
control source : blank

output control : text box
name : Start Account Name
control source : This is the bit I don't understand!

I have a table, tblSName, with an id field called sn_account and a name
field called sn_name. All I want to do is on entering a valid sn_account
value in the input control is to display the associated name in the second
box. It is not important that the code does not exist as sometimes I might
want all the codes with a particular prefix , other times a specific prefix.
My queries / reports work fine I just want to display associated information
when valid codes are entered.

Thanks
 
J

John W. Vinson

form name - frm SalesHistoryView
input control : text box
name : Start Account
control source : blank

output control : text box
name : Start Account Name
control source : This is the bit I don't understand!

I have a table, tblSName, with an id field called sn_account and a name
field called sn_name. All I want to do is on entering a valid sn_account
value in the input control is to display the associated name in the second
box. It is not important that the code does not exist as sometimes I might
want all the codes with a particular prefix , other times a specific prefix.
My queries / reports work fine I just want to display associated information
when valid codes are entered.

There is nothing above, and nothing in your previous posts, about a "prefix".
Bear in mind - I cannot see your database!

Again, let me ask:

Do you want the user to be able to SELECT a valid sn_account from a list? Or
would you be willing to consider this as an option?

Or do you want the user to type any arbitrary text string, and if it happens
to match a valid sn_account, see the name?

Or do you want to be able to type A12 and have all accounts from A1200000 to
A12999999 displayed? If so, how do you want them all displayed - in a textbox,
in a subform, or what?

I know if I were a user I'd prefer the first, but maybe I'm not understanding.


John W. Vinson [MVP]
 
G

Guest

To use your words :
I would like "Or do you want the user to type any arbitrary text string, and
if it happens to match a valid sn_account, see the name? "

The prefix would just be the first part of the account reference and you
have format correct with your suggestion of A12 etc but waht you have
suggested is not what is required here.

Thanks for you time.
 
J

John W. Vinson

To use your words :
I would like "Or do you want the user to type any arbitrary text string, and
if it happens to match a valid sn_account, see the name? "

Ok... set the Control Source of the second textbox to

=DLookUp("[sn_name]", "[YourTableName]", "[sn_account] = '" &
[FirstTextboxName] & "'")

using your control names and tablenames.

Sorry about the confusion on my part!

John W. Vinson [MVP]
 
G

Guest

Thanks for the help and no problem on the misunderstanding.

I tried
=DLookUp("[sn_name]","[tblSName]","[sn_account] = ' " & [Start Account] & "
' ")

and after I enter a reference in the Start Account box the new text box
remains blank.

However this is an improvement from when I tried it and only got errors.

John W. Vinson said:
To use your words :
I would like "Or do you want the user to type any arbitrary text string, and
if it happens to match a valid sn_account, see the name? "

Ok... set the Control Source of the second textbox to

=DLookUp("[sn_name]", "[YourTableName]", "[sn_account] = '" &
[FirstTextboxName] & "'")

using your control names and tablenames.

Sorry about the confusion on my part!

John W. Vinson [MVP]
 
J

John W. Vinson

Thanks for the help and no problem on the misunderstanding.

I tried
=DLookUp("[sn_name]","[tblSName]","[sn_account] = ' " & [Start Account] & "
' ")

and after I enter a reference in the Start Account box the new text box
remains blank.

Requery the DLookUp control in the AfterUpdate event of the [Start Account]
control, then.

John W. Vinson [MVP]
 

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