Question : How do I import data from a view into multiple fields on a form

Hello,

Hoping for some help in regards to populating a stock take form with data from an existing view.
The form is to be completely  populated (100 + fields)  by referencing an updated lookup table (Products)  via the import button.
 
Eg Field 1,Field 2, Feild 3 are populated by row 1 data within the Products lookup view  then

Field 4, Field 5, Field 6 are populated by the next row of data (row 2) and so on until end of the Product  lookup view.
                  
      
Example of Stock take form below.
                  
ProdNumber      Description      Qty            
Field 1               Field 2              Field 3            Import Button
Field 4               Field 5              Field 6            
Field 7               Field 8              Field 9            
Upto 200  fields                        



Products Lookup View.                  

ProdNumber      Description      Qty            
1                           Pencil                      100            
2                           Eraser                      200            
3                           Ruler                      300            
4                           Pen                       400
5                           Book                      500
Up tp 200 items      


Thanks in advance
      

Answer : How do I import data from a view into multiple fields on a form

dbcolumn and dblookup returns a list with a value from each line in a view. They are in the same order for each column returned. So you pull the values and then use an @for to loopthrough them. You may want to think about renaming your fields. The code below works where each line has 3 fields. (prodfield, descfield and qtyfield) They all have their line # appended to them. The first line prodfield would be prodfield_1 and so on.

prodvals:=@db...(...prodcol);
descvals:=@db...(...desccol..);
qtyvals:=@db...(...qtycol..);
@for(i:=1;i<=@count(prodvals);i:=I+1;
   linenostr:=@text(i);
   @setfield("prodfield_"+ linenostr ; prodvals[i]);
   @setfield("descfield_"+linenostr ; descvals[i]);
   @setfield("qtyfield_"+linenostr ; qtyvals[i])
)

Random Solutions  
 
programming4us programming4us