临时表的有关问题

临时表的问题
我是个新手,想问个关于临时表的问题:
我建立了三张表,分别是:品牌表(品牌,型号);进库表(品牌,型号,数量,单位,金额);出库表(品牌,型号,数量,单位,金额).我想将三张表的内容放在一张临时表中,但在更新临时表时出错,不知道哪儿错了,请各位高手帮帮忙,谢谢!!!
代码如下:
Create cursor T2(品牌 C(16),型号 C(16),入库数量 N(10,0),入库金额 N(20,2),出库数量 N(10,2),出库金额 N(20,2),库存数量 N(10,2),操作人员 C(10))
Append from 品牌型号表
Goto top
pingpai=alltrim(T2.品牌)
xinghao=alltrim(T2.型号)
shul1=''
shul2=''
shul3=''
jine1=''
jine2=''
select 进库表
sum 数量 To shul1 for alltrim(品牌)=pingpai .and.alltrim(型号)=xinghao .and. month(进库日期)=mmonth .and.year(进库日期)=yyear
sum 金额 To jine1 for alltrim(品牌)=pingpai .and. month(进库日期)=mmonth .and.alltrim(型号)=xinghao .and.year(进库日期)=yyear
select 出库表
sum 数量 To shul2 for alltrim(品牌)=pingpai .and. month(出库日期)=mmonth .and.alltrim(型号)=xinghao .and.year(出库日期)=yyear 
sum 金额 To jine2 for alltrim(品牌)=pingpai .and. month(出库日期)=mmonth .and.alltrim(型号)=xinghao .and.year(出库日期)=yyear
select 库存表
locate for alltrim(品牌)=pingpai.and. alltrim(型号)=xinghao
if found()
shul3=int(数量)
else
shul3=0
endif
locate for alltrim(T2.品牌)=pingpai.and. alltrim(T2.型号)=xinghao
insert into T2.入库数量 values(int(shul)) *thisform.grid1.refresh
thisform.text2.value=int(shul3)
thisform.refresh
*enddo
endif
thisform.grid1.RecordSource='T2'
thisform.grid1.RecordSourceType=0
总是提示红字部分出错,说不存在T2。入库数量不存是

------解决方案--------------------
红色那一行改成如下:
Replace T2.入库数量 with int(shul)
thisform.grid1.refresh

或者:

update T2 set 入库数量=int(shul) where rtrim(品牌)=pingpai.and. rtrim(型号)=xinghao
thisform.grid1.refresh