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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo box use on form

Status
Not open for further replies.

keepingbusy

Programmer
Apr 9, 2000
1,470
GB
Hi

This is a duplicate posting from the Microsoft: VFP -General Coding Issues that I have been requested to show here.

Before you look at it, I had some replies on the original thread. The second issue about not wanting anyone to add thier own description has been resolved by changing the combo box style property to 2 - Dropdown List

Whilst trying to develop this, I have another question as 3 below.

Original Post:

Sorry if this seems easy to you guys, but I've not had much call in the past to use combo boxes on a form and the help file (as usual) doesn't give you much info.

I have used the following with advice from another thread to create an array:

Code:
DIMENSION shortcodes(1)
IF file("scodes.dbf")
  SELECT shortcode FROM scodes ORDER BY shortcode ;
    INTO ARRAY shortcodes
ENDIF

The combo box on the forms works fine having used the builder to allow the combo box to be populated with the array data from the table called scodes but here are my issues:

1. When the form runs, I need the first record in that array to show as the first line in the combo box

2. I do not want to allow anyone to add their own descriptions into that combo box (only allow the choices from the array)

3. The the scodes.dbf has two fields shortcode and codedesc An example of one of the records is OPTION1 in the first field and 2006 in the second field. One of the records I've used the builder on the combo box to allow the first field from another table to be populated by the selection from the array when the user selects it from the combo box. If I want the second field to be populated in the secnd table from the array when the user selects the first, how is that accomplished? Can the builder do it?

Some guidance not the sollution would be appreciated.

Version VFP9

Many thanks as always.

Lee
 
Where is this code in the form.

I would :
1. make a form.proprty of the array and initilize it in the form load method.

2. Make it a Combobox property and initilize it in the combox init()

If you do not make it a property of the form / Combobox, it will not survive the method it was created in.

Option #3
Before the form is called, make it a public array but make sure you release it after the form end. ( I do not recommend this option but it exist.)

David W. Grewe Dave
 

Dave

Thank you for the very quick response. In the interim I tried out a list box and this appears to be working fine having been populated by the array.

Whilst I accept list boxes can take up slightly more room on a form (although you can decrease its length down to a couple of lines), do you (or anyone else) think this could cause any other issues in the future?

Lee
 
List Box, ComboBox, It is your choice as to how the form looks, I like combo boxes. List boxes give the user the idea they can add items. Do not get those questions from combo boxes.

David W. Grewe Dave
 

Dave

Sincerest thanks for the advice. Rather than complicate things I'm going to run with the list box.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top