| View previous topic :: View next topic |
| Author |
Message |
2byte Newbie

Joined: 05 Mar 2010 Posts: 3
|
Posted: Fri Mar 05, 2010 9:32 am Post subject: [Solved] Use two fields from Combobox SQL? |
|
|
New guy here, using base with MYSql database.
I have a form with subform. The main form displays customers and the subform shows their orders.
The customers table has a autovalue primary key of cust_id.
There is a comobox loaded with all of the customer names that when selected filters the main form to show the customer's info and the subform is reloaded to match.
I have discovered that when I apply a filter to the main form such as name = 'Ajax' then the main form cannot alter the customer's name in the textbox linked to the name field of the table. This makes sense to me.
If I modify the SQL for the combobox to
SELECT DISTINCT `name` `cust_id` FROM `company`.`customers`
how can I retrieve the cust_id from the combobox or its recordset and use that to filter the form?
If that is not possible is there a work-around?
Thanks
Last edited by 2byte on Sat Mar 06, 2010 5:32 am; edited 1 time in total |
|
| Back to top |
|
 |
QuazzieEvil Super User

Joined: 17 Jan 2007 Posts: 599 Location: Houston, TX
|
|
| Back to top |
|
 |
2byte Newbie

Joined: 05 Mar 2010 Posts: 3
|
Posted: Fri Mar 05, 2010 12:23 pm Post subject: |
|
|
Thanks for the quick reply! I have done as you suggested and switched to a listbox. I unbound the field as it is not to modify any table field itself. The query for it is SELECT `name` `cust_id` FROM `company`.`customers` .
I am still baffled as to how to get the value of cust_id from the current selected listbox item. Is there an explanation or example available?
Thanks |
|
| Back to top |
|
 |
2byte Newbie

Joined: 05 Mar 2010 Posts: 3
|
Posted: Sat Mar 06, 2010 5:32 am Post subject: |
|
|
| Ah, now I see. The listbox data field must be the same as the pk field in the form. |
|
| Back to top |
|
 |
|