Click to See Complete Forum and Search --> : combo-box
fly_phoenix
Aug 25th, 2000, 04:42 AM
I can't seem to get the following done.
I have a database with 3 tables: 1 for Employees(table a) 1 for products(table b) and one for use of products by employees (table c).
Now I want to create a form in which a combo gives the opportunity to select one employee from table a, another combo gives the opportunity to select one product from table, and writes the selected choise down in table c.
But my combo only shows the first employee or product it can find.
How do I fix this?
And to make it more complicated, in the combo I want to see the description of the field, but in table c I want to write down the indentifier.
How can I do this? Anyone know?
HunterMcCray
Aug 25th, 2000, 09:53 AM
Originally posted by fly_phoenix
I can't seem to get the following done.
I have a database with 3 tables: 1 for Employees(table a) 1 for products(table b) and one for use of products by employees (table c).
Now I want to create a form in which a combo gives the opportunity to select one employee from table a, another combo gives the opportunity to select one product from table, and writes the selected choise down in table c.
But my combo only shows the first employee or product it can find.
How do I fix this?
And to make it more complicated, in the combo I want to see the description of the field, but in table c I want to write down the indentifier.
How can I do this? Anyone know?
It sounds like you are expecting VB to know what you want it to do without telling it. Assuming that you are using Data-Bound combo boxes for a and b, and that you want to limit the choices for a and b to the tables that they are bound to you need to decide which event will trigger the creation of a new entry in the third table. I would suggest using a data-bound grid for the third control, and I would suggest adding a command button to trigger the "Add Record" event. If you use this format then all you need to do is use an SQL statement to insert the new record into the third table when the "Add Record" event is triggered, you can then refresh the dbgrid control's data control to display only entries with that employee, product or both. I would suggest including a date field that has a default value of Now....but that is up to you. Remember that a bound control only displays data that is already in a table.
If you want to achieve this in a simple way I would suggest that you use MS Access to force the fields "Employee" and "Product" to be look-up fields in the third table. Then all you have to do is use a data-bound grid control to display the fields "Employee" and "Product". Set the grid control's "Allow Add New" property to True and then every time you select a new employee or product on the last line of the grid a new entry will be created in your third table.
Hope this helps,
Hunter
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.