Code to Perform Task

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

Guest

Hi

Could someone help me with the correct code to perform this desired task as
I am having grave diffciulty getting it done.

A user selects the security description from the combox box, which
disappears and then brings up the correct symbol to match the description.
The user should not be typing in any information, as we are trying to
eliminate human error.

Symbol Security Description
E.g. CME Chicago Mercantile Exchange

I have created a table with the symbol and the description to match as seen
in the above example.

What code would I need to use to allow this to work.

Thanks
 
microsoft said:
Hi

Could someone help me with the correct code to perform this desired
task as I am having grave diffciulty getting it done.

A user selects the security description from the combox box, which
disappears and then brings up the correct symbol to match the
description. The user should not be typing in any information, as we
are trying to eliminate human error.

Symbol Security Description
E.g. CME Chicago Mercantile Exchange

I have created a table with the symbol and the description to match
as seen in the above example.

What code would I need to use to allow this to work.

No code is needed. Build the combo box like this (substituting your
table, field, and control names as appropriate):

Combo box properties
--------------------------
Name: cboSecurity
RowSource Type: Table/Query
RowSource:
SELECT [Symbol], [Description]
FROM tblSecurities ORDER BY [Description];
BoundColumn: 1
ColumnCount: 2
ColumnWidths: 0"; 2"

Also create a text box on your form to show the symbol for the selected
security. You can do that simply by giving the text box a ControlSource
of

=[cboSecurity]

Is the security Symbol supposed to be stored in a field in the form's
recordsource table? If so, set the ControlSource of the *combo box* to
the name of that field.
 
Thanks for your response.

As per your guidance, I have created a table called SecurityExchange

Fields (in this order)
Description
Symbol

Table Contents
TSE Toronto Stock Exchange
VAN Vancover Stock Exchange

However, we still are missing one element. The user should be seeing the
Descriptions first. Once a description is selected the corresponding symbol
should appear in the combox box on the form as the result. The user has to
be able to see the descriptions first to ensure that the corresponding
correct symbol is chosen.
Is this any clearer.

Thanks for your help thus far, looking forward to hearing from you.

Dirk Goldgar said:
microsoft said:
Hi

Could someone help me with the correct code to perform this desired
task as I am having grave diffciulty getting it done.

A user selects the security description from the combox box, which
disappears and then brings up the correct symbol to match the
description. The user should not be typing in any information, as we
are trying to eliminate human error.

Symbol Security Description
E.g. CME Chicago Mercantile Exchange

I have created a table with the symbol and the description to match
as seen in the above example.

What code would I need to use to allow this to work.

No code is needed. Build the combo box like this (substituting your
table, field, and control names as appropriate):

Combo box properties
--------------------------
Name: cboSecurity
RowSource Type: Table/Query
RowSource:
SELECT [Symbol], [Description]
FROM tblSecurities ORDER BY [Description];
BoundColumn: 1
ColumnCount: 2
ColumnWidths: 0"; 2"

Also create a text box on your form to show the symbol for the selected
security. You can do that simply by giving the text box a ControlSource
of

=[cboSecurity]

Is the security Symbol supposed to be stored in a field in the form's
recordsource table? If so, set the ControlSource of the *combo box* to
the name of that field.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
microsoft said:
Thanks for your response.

As per your guidance, I have created a table called SecurityExchange

Fields (in this order)
Description
Symbol

Table Contents
TSE Toronto Stock Exchange
VAN Vancover Stock Exchange

Your table contents appear to have the fields backward, according to
your field order.
However, we still are missing one element. The user should be seeing
the Descriptions first. Once a description is selected the
corresponding symbol should appear in the combox box on the form as
the result. The user has to be able to see the descriptions first to
ensure that the corresponding correct symbol is chosen.
Is this any clearer.

So at any given time you want the user to see either the Description, or
the Symbol, but never both at the same time? That would involve some
code, after all. Why do you have this requirement? If the user is
never to enter the symbol, why show it at all? They can pick a
description and you can still have the symbol stored in the table.

What if they have to go back and change the Exchange, after they've
already chosen one (so the symbol is now displayed)? How should the
combo box behave? Hmm, we could have it show the description whenever
it has the focus, and show the symbol whenever it doesn't have the
focus. That might suit your needs, but it seems a little odd to me.
 
Hi

Could someone help me with the correct code to perform this desired task as
I am having grave diffciulty getting it done.

A user selects the security description from the combox box, which
disappears and then brings up the correct symbol to match the description.
The user should not be typing in any information, as we are trying to
eliminate human error.

Symbol Security Description
E.g. CME Chicago Mercantile Exchange

I have created a table with the symbol and the description to match as seen
in the above example.

What code would I need to use to allow this to work.

Thanks

I'm not at all sure I understand what's not working, or what you
expect to happen. What is the "task"? In what way is using the combo
box forcing the user to type something? What do you want to do with
the symbol value once it's been selected?

John W. Vinson[MVP]
 
You don't need any code.

Just make sure your symbol is the PK of the table.

Build a combo box with two columns, make the first column (symbol) a length
of zero). In fact, the wizard will do this for you.

If you want, you can show descriptions + symbol in the comb box, by having 3
columns (repeat the symbol column again "after" the description).

Now, right beside the combo box, simply place a text box, and make the data
source of the text box the SAME as the field that the combo box is bound to.

You don't need one line of code here....
 
HI

Thanks for all your responses they have all been very helpful.

One more thing. The combox field is working correctly in that a user
selects a description and the corresponding symbol is displayed in the
textbox based on the information provided in the previous posts.

However, what if another field was added to the database, currency.

What should happen now, is that when a user selects the description from the
combo box the description and the currency matching should be displayed in
the two textboxes created. What would I need to do to get the currency
showing. I have the description and symbol appearing.

Thanks so much.

Regards
 
microsoft said:
HI

Thanks for all your responses they have all been very helpful.

One more thing. The combox field is working correctly in that a user
selects a description and the corresponding symbol is displayed in the
textbox based on the information provided in the previous posts.

However, what if another field was added to the database, currency.

What should happen now, is that when a user selects the description
from the combo box the description and the currency matching should
be displayed in the two textboxes created. What would I need to do
to get the currency showing. I have the description and symbol
appearing.

If you did it the way I originally suggested, then add the new field as
a third column to the combo box. Change the combo box's properties as
follows:

Combo box properties
--------------------------
Name: cboSecurity
RowSource Type: Table/Query
RowSource:
SELECT [Symbol], [Description], [Currency]
FROM tblSecurities ORDER BY [Description];
BoundColumn: 1
ColumnCount: 3
ColumnWidths: 0"; 2"; 0"

And create the new text box to display the [Currency] column from the
combo box, giving it a ControlSource like this:
of

=[cboSecurity].[Column](2)

Note that the above expression actually refers to the third column of
the combo box, because the Column property of a combo box is 0-based.
 
Back
Top