Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with combo

Status
Not open for further replies.

Judi201

Technical User
Jul 2, 2005
315
US
Hi!

I have read the many threads here and know they are telling me what I need to know, if I could just get it together, but so far no luck.

I have a page used to enter an order. I want to use a combo to give the user the selection of a shipping address. The customer may have several (usually 1-5). This info is in a table. I want to use a query to populate a combo with possible addresses (from the shipping table) related to the current customer number. The selection will be stored (address #) in a field of the orders table.

If I place the combo on the page, where can I put the code for the query that will know the current customer number and be there when needed by the combo. I hope this question makes some sense as it is not clear to me exactly what I need. I know the timing is the important thing and I am lost.

Any help much appreciated. VFP 6.0

Judi
 
I assume you have selected a customer previously, hopefully in the same form. I will try to answer that possiblility first.

If the customer is selected on the same form then you can have code in the VALID of the control that selected the customer.

Valid code:
Select <addresses> ;
from <shippingtable> ;
where <customernumber> = orders.customernumber ;
order by <addresses> ;
into cursor csrCustomerAddresses

NOW in the combo, set the ROWSOURCE to csrCustomerAddresses.<ADDRESSES> and the ROWSOURCETYPE to FIELDS.

In the valid of the combo you can use something like this:
select orders
replace <shippingaddress> with this.value

Not tested but should get you close.

Don Higgins




Don Higgins
 
If the form is not the one where you selected the customer then you need to pass a parameter to the form that displays the addresses.

If you are going to do this let us know.

*****
By the way, in the first answer I assumed you selected the customer number and already stored it in the orders table. If not then you will have to find some way to get the select statement a primary key value so it can do a proper select.


Don Higgins
 
Hi Don,

Thanks for the response. I will try this in the morning.
Yes, my customer is already selected and on the same form. I understand how to do all that you suggested, I just didn't know where I could put the code for query. I thought I had read that it had to be in the 'load of the form' or added programatically and I didn't follow.

I will let you know how it goes. Gotta go now.

Many thanks.

Judi
 
I have a page used to enter an order. I want to use a combo to give the user the selection of a shipping address. The customer may have several (usually 1-5). This info is in a table. I want to use a query to populate a combo with possible addresses (from the shipping table) related to the current customer number. The selection will be stored (address #) in a field of the orders table.

If I place the combo on the page, where can I put the code for the query that will know the current customer number and be there when needed by the combo. I hope this question makes some sense as it is not clear to me exactly what I need. I know the timing is the important thing and I am lost.

In order to work with the combo box, you have to understand how its properites and methods work. I wrote Chapter 5 - "Combos and lists" of "1001 Things You Wanted to Know About Visual FoxPro" ( ) back in 2000 using VFP version 6 so all the code samples and text will apply to your situation. You do not have to purchase the book to get the benefit of the expalanation in this chapter - it is one of the free sample chapters available at Of course, you do not get the sample code with the free chapter, but you get the explanation of how combos work (which is supplied in the text):

Here is a partial list of topics covered in that chapter:

Chapter 5: Combos and Lists
Combo and list box basics
List and ListItem collections
When do the events fire?
How do I bind my combo and list boxes?
How do I refer to the items in my combo and list boxes?
What is the difference between DisplayValue and Value?
What's the difference between RowSourceTypes "alias" and "fields"?
How do I make my combo and list boxes point to a particular item?
How do I add new items to my combo and list boxes?
How do I filter the items displayed in a second combo or list box based on the selection


Marcia G. Akins
 
Hi Marcia,

I have your wonderful book, "1001 Things..", that I have used for so many things in this project. Most of my classes are based on something included there.

Somehow, I could not find exactly what I was confused about in there this time. I have used combo and list boxes in several other places successfully, but always on a form that I was loading apart from the pageframe.

I will try Don's suggestion and reread the Chapter and look again at the examples in Chapter 5 and report back. (Smarter, I am sure)[smile]

Thanks

Judi
 
Don,

I worked through the instructions with no problem. Really, all I didn't get was where to put the code. Sometimes I read something and go off a strange tangent and had convinced myself that I could not just set it up on the page like that.[sad]

Easy enough.
****
Marcia, thanks for the response. I learned more by rereading.

Judi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top