Search code examples
databasedata-bindingvisual-foxprofoxpro

How to see the controlsource and the display source properties?


I have two tables, user and company, and I have a combo box in which I list all the companies I have in the company table. My question is, how to use databinding in foxpro to display the company name? When I save the information to the database, I only need to save the company ID; same for display, from the company ID I have in my user table, I would like to display the company name. I tried using the properties :

CmbCompany.controlesource = myTable.companyID
cmbCompany.displaysource = myTable.companyName

but this doesn't work, I missing something!


Solution

  • Set the RowSource for the combo so that it puts the data you want to show in the first column, and the value you want to store in the second. Set BoundColumn to 2 and, if your ID field is numeric or integer, set BoundTo to .T.

    I'd do all this in the property sheet, but something like this:

    RowSourceType = 6-Fields
    RowSource = Company.CompanyName, ID
    BoundColumn = 2
    BoundTo = .T.
    ControlSource = MyTable.CompanyID
    

    Tamar