First, I am new in alpha Five, I am using V10.
I have 2 tables, in the first I have all the field related to a Employee and in the second table I have 2 fields, the first field(Valor acumulado) is a value which I have to find and then use the second field( Valor normalizado)
I solve it by using Xbasic and it works but I want to know if using the Lookup with an external table it's better.
I tried it but allways got error .
Fieldx = Lookup("table2","variable_1 = valoracumulado","valornormalizado")
!!! for me is to look in table 2, the value of the table1 equal to a field in table 2 and if its found then return the value from table 2 to a fieldx.
thanks in advance for all your help, and sorry if my english is not so good .
Angel(Saltillo, Mexico)
dim tbl as p
dim tbl2 as p
dim varnormalizada as N
'Read in a sequential way all the first table
tbl = table.open("datos_preguntas")
tbl.fetch_first()
While .not. tbl.fetch_eof()
'look in the secod table for the value of Variable_1 which in in the table 1
tbl2 = table.open("Tabla2")
tbl2.fetch_first()
While .not. tbl2.fetch_eof()
If tbl.variable_1 = tbl2.valoracumulado then
varnormalizada = tbl2.valornormalizado
end if
tbl2.fetch_next()
end while
tbl.change_begin(.t.)
tbl.variable1norm = varnormalizada
tbl.change_end(.t.)
tbl2.close()
tbl.fetch_next()
end while
tbl.close()
I have 2 tables, in the first I have all the field related to a Employee and in the second table I have 2 fields, the first field(Valor acumulado) is a value which I have to find and then use the second field( Valor normalizado)
I solve it by using Xbasic and it works but I want to know if using the Lookup with an external table it's better.
I tried it but allways got error .
Fieldx = Lookup("table2","variable_1 = valoracumulado","valornormalizado")
!!! for me is to look in table 2, the value of the table1 equal to a field in table 2 and if its found then return the value from table 2 to a fieldx.
thanks in advance for all your help, and sorry if my english is not so good .
Angel(Saltillo, Mexico)
dim tbl as p
dim tbl2 as p
dim varnormalizada as N
'Read in a sequential way all the first table
tbl = table.open("datos_preguntas")
tbl.fetch_first()
While .not. tbl.fetch_eof()
'look in the secod table for the value of Variable_1 which in in the table 1
tbl2 = table.open("Tabla2")
tbl2.fetch_first()
While .not. tbl2.fetch_eof()
If tbl.variable_1 = tbl2.valoracumulado then
varnormalizada = tbl2.valornormalizado
end if
tbl2.fetch_next()
end while
tbl.change_begin(.t.)
tbl.variable1norm = varnormalizada
tbl.change_end(.t.)
tbl2.close()
tbl.fetch_next()
end while
tbl.close()
Comment