Search code examples
for-loopwhile-loop

Loop data search in FoxPro


I have a table name " Prod_Master" where some different uniq data in column "Item" (e,g 111, 178, 19024 . .). Now I want to brows these data from another table name "Item_Master" where the same value in same column name "Item" one by one (with loop program). This brows program will continue till the end of last record of "Prod_Master".

Select a Use Prod_Master m.code= Item Use Item_Master Brow for item=code


Solution

  • Let's see if I understand your question correctly... In table Prod_Master you have a field named "Item". You also have a table "Item_Master" with a field that is also named "Item".

    Assuming this is correct, your question if I am understanding you correctly, is to "loop" through all of the records in the Prod_Master table and display a BROWSE window in Item_Master for each matching record in Prod_Master.

    One option would be to write a short program as follows:

    select item from prod_master into cursor tCursor
    select('tCursor')
    scan
      select * from item_master where item_master.item == prod_master.item into cursor tQuery
      select('tQuery')
      browse
      select('tCursor')
    endscan
    

    It is possible to have the second select statement in the item_master table display the browse window directly without having to store the data in tQuery but this solution gives you more control over the Item_master table if needed (for example make it ReadWrite and modify the data in just one column.

    Please remember to accept this answer if it helps.