主题:代码问题
笨兔
[专家分:300] 发布于 2008-08-07 13:18:00
SCAN
nOlm_35=IIF(ISNULL("m_35")=.T.,0,m_35)
nOlm_36=IIF(ISNULL("m_36")=.T.,0,m_36)
nOlm_37=IIF(ISNULL("m_37")=.T.,0,m_37)
SELECT tblStock
LOCATE FOR ALLTRIM(tblstock.product)==ALLTRIM(curin.product)and ALLTRIM(tblstock.color);
==ALLTRIM(curin.color)
IF FOUND()
replace tblstock.m_35 WITH tblstock.m_35+(curin.m_35-nolm_35)
replace tblstock.m_36 WITH tblstock.m_36+(curin.m_36-nolm_36)
replace tblstock.m_37 WITH tblstock.m_37+(curin.m_37-nolm_37)
ELSE
INSERT INTO tblstock (product,color,m_35,m_36,m_37) VALUES ;
(curin.product,curin.color,curin.m_35 ,curin.m_36 ,curin.m_37 )
ENDIF
ENDSCAN
问题是:没找到时,记录输入不进去.
回复列表 (共11个回复)
沙发
cbl518 [专家分:57140] 发布于 2008-08-07 13:58:00
SCAN
nOlm_35=IIF(ISNULL("m_35")=.T.,0,m_35)
nOlm_36=IIF(ISNULL("m_36")=.T.,0,m_36)
nOlm_37=IIF(ISNULL("m_37")=.T.,0,m_37)
SELECT tblStock
LOCATE FOR ALLTRIM(tblstock.product)==ALLTRIM(curin.product)and ALLTRIM(tblstock.color);
==ALLTRIM(curin.color)
IF FOUND()
replace tblstock.m_35 WITH tblstock.m_35+(curin.m_35-nolm_35)
replace tblstock.m_36 WITH tblstock.m_36+(curin.m_36-nolm_36)
replace tblstock.m_37 WITH tblstock.m_37+(curin.m_37-nolm_37)
ELSE
nrecn=RECNO()
INSERT INTO tblstock (product,color,m_35,m_36,m_37) VALUES ;
(curin.product,curin.color,curin.m_35 ,curin.m_36 ,curin.m_37 )
GO (nrecn)
ENDIF
ENDSCAN
板凳
cbl518 [专家分:57140] 发布于 2008-08-07 14:01:00
SCAN
nOlm_35=IIF(ISNULL("m_35")=.T.,0,m_35)
nOlm_36=IIF(ISNULL("m_36")=.T.,0,m_36)
nOlm_37=IIF(ISNULL("m_37")=.T.,0,m_37)
SELECT tblStock
LOCATE FOR ALLTRIM(tblstock.product)==ALLTRIM(curin.product) ;
and ALLTRIM(tblstock.color)==ALLTRIM(curin.color)
IF FOUND()
replace tblstock.m_35 WITH tblstock.m_35+(curin.m_35-nolm_35);
,tblstock.m_36 WITH tblstock.m_36+(curin.m_36-nolm_36);
,tblstock.m_37 WITH tblstock.m_37+(curin.m_37-nolm_37)
ELSE
nrecn=RECNO()
INSERT INTO tblstock (product,color,m_35,m_36,m_37) ;
VALUES(curin.product,curin.color,curin.m_35 ,curin.m_36 ,curin.m_37 )
GO (nrecn)
ENDIF
ENDSCAN
3 楼
cbl518 [专家分:57140] 发布于 2008-08-07 14:10:00
以上代码组,
应该用两句语句替代,
这样效率就大大的提高了。
4 楼
笨兔 [专家分:300] 发布于 2008-08-07 14:18:00
谢谢CBL518大师
请问两句代码怎样写给点提示.
5 楼
笨兔 [专家分:300] 发布于 2008-08-07 14:40:00
运行时提示找不到m_35变量
6 楼
cbl518 [专家分:57140] 发布于 2008-08-07 15:25:00
谁知道你的 m_35 是什么啊!
[color=FF0000]sele 表别名[/color]
SCAN
nOlm_35=IIF(ISNULL("m_35")=.T.,0,[color=FF0000]m_35[/color])
nOlm_36=IIF(ISNULL("m_36")=.T.,0,m_36)
nOlm_37=IIF(ISNULL("m_37")=.T.,0,m_37)
……
7 楼
笨兔 [专家分:300] 发布于 2008-08-07 15:44:00
m_35是临时表中的字段.我改了后还是加不上.
8 楼
笨兔 [专家分:300] 发布于 2008-08-07 15:49:00
select curin
SCAN
nOlm_35=IIF(ISNULL("m_35")=.T.,0,m_35)
nOlm_36=IIF(ISNULL("m_36")=.T.,0,m_36)
nOlm_37=IIF(ISNULL("m_37")=.T.,0,m_37)
SELECT tblStock
LOCATE FOR ALLTRIM(tblstock.product)==ALLTRIM(curin.product)and ALLTRIM(tblstock.color);
==ALLTRIM(curin.color)
IF FOUND()
replace tblstock.m_35 WITH tblstock.m_35+(curin.m_35-nolm_35)
replace tblstock.m_36 WITH tblstock.m_36+(curin.m_36-nolm_36)
replace tblstock.m_37 WITH tblstock.m_37+(curin.m_37-nolm_37)
ELSE
nrecn=RECNO()
INSERT INTO tblstock (product,color,m_35,m_36,m_37) VALUES ;
(curin.product,curin.color,curin.m_35 ,curin.m_36 ,curin.m_37 )
GO (nrecn)
ENDIF
ENDSCAN
9 楼
cbl518 [专家分:57140] 发布于 2008-08-07 18:24:00
[quote]m_35是临时表中的字段.我改了后还是加不上.[/quote]
你把问题叙述清楚些,
你是怎么改数据的???
有时怎么添加的???
加不上什么???
往那个什么(来源?)表,添加数据。
说清楚后,把你的文件上传。
10 楼
cbl518 [专家分:57140] 发布于 2008-08-07 18:30:00
select curin
SCAN
nOlm_35=IIF(ISNULL(m_35),0,m_35)
nOlm_36=IIF(ISNULL(m_36),0,m_36)
nOlm_37=IIF(ISNULL(m_37),0,m_37)
SELECT tblStock
LOCATE FOR ALLTRIM(tblstock.product)==ALLTRIM(curin.product) ;
and ALLTRIM(tblstock.color)==ALLTRIM(curin.color)
IF FOUND()
replace tblstock.m_35 WITH tblstock.m_35+(curin.m_35-nolm_35);
,tblstock.m_36 WITH tblstock.m_36+(curin.m_36-nolm_36);
,tblstock.m_37 WITH tblstock.m_37+(curin.m_37-nolm_37) in tblstock
ELSE
nrecn=RECNO("curin")
INSERT INTO tblstock (product,color,m_35,m_36,m_37) ;
VALUES(curin.product,curin.color,curin.m_35 ,curin.m_36 ,curin.m_37 )
GO (nrecn) in curin
ENDIF
select curin
ENDSCAN
我来回复