OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

[Solved] Use two fields from Combobox SQL?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
2byte
Newbie
Newbie


Joined: 05 Mar 2010
Posts: 3

PostPosted: Fri Mar 05, 2010 9:32 am    Post subject: [Solved] Use two fields from Combobox SQL? Reply with quote

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
View user's profile Send private message
QuazzieEvil
Super User
Super User


Joined: 17 Jan 2007
Posts: 599
Location: Houston, TX

PostPosted: Fri Mar 05, 2010 9:36 am    Post subject: Reply with quote

use a list box instead, as a combo does not allow multiple columns in source. A list box can be made to look like a combo by selecting the dropdown option in the props dialog.
_________________
Free Docs @ http://www.baseprogramming.com/resources.html
Book @ lulu.com http://www.lulu.com/content/2455551
Back to top
View user's profile Send private message Visit poster's website
2byte
Newbie
Newbie


Joined: 05 Mar 2010
Posts: 3

PostPosted: Fri Mar 05, 2010 12:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
2byte
Newbie
Newbie


Joined: 05 Mar 2010
Posts: 3

PostPosted: Sat Mar 06, 2010 5:32 am    Post subject: Reply with quote

Ah, now I see. The listbox data field must be the same as the pk field in the form.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group