Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function Copies Record But also inserts Blank records

Status
Not open for further replies.

evr72

MIS
Dec 8, 2009
265
US
Hello,

I have a function that copies records from one table to another table, this works well, but it also inserts blank records and I am not sure how to stop this.
any advice is greatly appreciated!!

Code:
Function BeforeProcessMenu(conn)
      set dal_mbcnrpx3=dal.Table("mbcnrpx3")

set dal_pick=dal.Table("pick")

set rstmp = dal_mbcnrpx3.QueryAll()
set rstmp01 = dal_pick.QueryAll()

sql="select CNKZNB from mbcnrpx3"
set rsExistsCU=CustomQuery(sql)
if rsExistsCU.eof then
	sqlInsert="Update pick set Pick_list='"& CNKZNB &"' where '"& CNKZNB &"'<>''"
       CustomQuery(sqlInsert)
end if
rsExistsCU.close
set rsExistsCU=nothing



while not rstmp.eof
'add each record from mbcnrpx3 table to the pick table 
set rsExist = dal_pick.Query("Pick_list=" & rstmp("CNKZNB") & " and Order_Num='" & rstmp("CNCVNB")  & "'","")
if rsExist.eof then 

dal_pick.Item_Num=rstmp("CNAITX")
dal_pick.Pick_list=rstmp("CNKZNB")
dal_pick.Order_Num=rstmp("CNCVNB")
dal_pick.Create_date=rstmp("CNALDT")
dal_pick.Create_time=rstmp("CNABTM")
dal_pick.pick_qty=rstmp("CNANQT")



end if
dal_pick.Add()


set rsExist = nothing


rstmp.movenext

wend
set rstmp=nothing   

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top