VFP - combobox retrieving values ?

Hi Experts

I'm facing a problem in retrieving the column sb_cccx that has the code associated with the description (like bellow)  from a combo when clicking in an combo option during edition:

Select SB_CCCX, Desc From CCCX;
      ORDER By Desc;
      WHERE SB_EMP = m.SB_EMP And;
      INTO Cursor temp_cccx

tam = _Tally
If tam>0
      Go Top
            Thisform.pageframe1.page1.cmbCCCx1.List(i) = temp_cccx.Desc
            i = i+1
How to code to  make  thisform.msb_cccx property to have the correct value when the user clicks the option ?

Eduardo FuerteDeveloper and AnalystAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If the SB_CCCX is a string then it is relatively easy:

Create combo containing two columns (CoulmnCount = 2), place the displayed value to the first column and the value which should be stored to the RowSource has to be in column 2.

Populate the combo with the following code:

i = 1
      Thisform.pageframe1.page1.cmbCCCx1.List(i,1) = temp_cccx.Desc
      Thisform.pageframe1.page1.cmbCCCx1.List(i,2) = temp_cccx.SB_CCCX
      i = i+1

and the BounColumn value should contain column number which will be stored into RowSource.

If you would like to suppress the second column display in the Combo then you may set its Column width to zero (ColumnWidths = "100,0")

You could also use Combo.RowSourceType = 2 and RowSource = "temp_cccx" and then the combo item selection selects a row from your cursor directly and you don't need to populate the List array.

I would recommend to buy Hacker's Guide to Visual FoxPro (http://www.hentzenwerke.com/catalog/hackfox7.htm) which contains many useful hints and explains how Combo works on different data types very deeply.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Eduardo FuerteDeveloper and AnalystAuthor Commented:
Hi, Pcelba

Using the initial suggestion the only problem is to obtain existing values in the combo when open the form and navegating betwenn registers (it comes empty)

What is needed to workaround it ?

The combo should be populated in Form Init method or elsewhere. Where is your code to create Combo contents?

What are all non-default properties for the combo?

Did you try to look at combop properties in debugger?
Eduardo FuerteDeveloper and AnalystAuthor Commented:

Sorry the delay....

I've checked some properties and made some code adjusts and evereythings is ok...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.