-2

I'm newly introduced in visual foxpro and having some difficulties

I have combobox(combo1),listbox(list1),and tables(table1 and table2) combo1's rowsource is table1.records If I select a record in combo1, it will display all data from table2 to list1

Is it possible to do this? Thanks for your help :)

Mav
  • 1
  • 1
  • Dear Mav, I feel like what you are asking is simple with VFP, but still, I have to admit it is not understandable what you want to do. Would you provide some sample. Below I will provide a sample just shooting in the dark using Northwind sample data (Customers in combobox, when you select, selected Customer's Orders show in listbox) - not sure if you meant something like that. – Cetin Basoz Sep 03 '18 at 17:30

1 Answers1

0

Remember this is just a sample built on a 'guess':

Public oForm
oForm = Createobject('SampleForm')
oForm.Show()


Define Class SampleForm As Form
    Height = 800
    Width=600
    DataSession = 2
    Add Object cmbCustomers As ComboBox With Top=10, Left=10, Width=250
    Add Object lstOrders As ListBox With Top=10, Left=280, Height=780, Width=310

    Procedure Init
        With This.cmbCustomers
            .RowSourceType = 3 && -SQL
            .RowSource = "select CompanyName, CustomerId from ('"+;
                _Samples+;
                "Northwind\Customers') into cursor crsCustomers nofilter"
            .ListIndex=1
        Endwith
        With This.lstOrders
            .RowSourceType = 3 && -SQL
            .RowSource = "select OrderId, OrderDate, ShippedDate, CustomerId from ('"+;
                _Samples+;
                "Northwind\Orders') o"+;
                " where o.CustomerId = crsCustomers.CustomerId"+;
                " into cursor crsOrders nofilter"
            .ColumnCount = 3
            .ColumnWidths = '70,120,120'
        Endwith
    Endproc

    Procedure cmbCustomers.InteractiveChange
        With Thisform.lstOrders
            .ListIndex = 0
            .Requery()
        Endwith
    Endproc
Enddefine
Cetin Basoz
  • 22,495
  • 3
  • 31
  • 39