想 根据 发货单的数量(当前订单编号=Text1(0).Text) 去修改 [库存纪录].[数量],下面的执行成功,但是数据库里没有更改!!!txtSQL = "update [库存纪录] set [库存纪录].[数量]=[库存纪录].[数量]-[发货表].[数量] from [库存纪录],[发货表] where [发货表].[配件编号]=[库存纪录].[配件编号] and [发货表].[原厂编号]=[库存纪录].[原厂编号] and [发货表].[订单编号]='" _
             & Trim(Text1(0).Text) & "'"
   Set mrc = ExecuteSQL(txtSQL, MsgText)

解决方案 »

  1.   

    txtSQL = "update [库存纪录] set [库存纪录].[数量]=[库存纪录].[数量]-[发货表].[数量] from [库存纪录] inner join [发货表] on [发货表].[配件编号]=[库存纪录].[配件编号] and [发货表].[原厂编号]=[库存纪录].[原厂编号] where [发货表].[订单编号]='" _
                 & Trim(Text1(0).Text) & "'"Set mrc = ExecuteSQL(txtSQL, MsgText)要保证一对一的关系啊
      

  2.   

    这也许跟你打开记录集的方法有关 比如:
       rs.cursortype=3
       rs.locktype=2
       等等
    还是单步执行一下看看 问题总会找到的
      

  3.   

    update [库存纪录] 
    set [库存纪录].[数量]=[库存纪录].[数量]-(Select [发货表].[数量] from [库存纪录],[发货表] where [发货表].[配件编号]=[库存纪录].[配件编号] and [发货表].[原厂编号]=[库存纪录].[原厂编号] ) 
    where [发货表].[配件编号]=[库存纪录].[配件编号] and [发货表].[原厂编号]=[库存纪录].[原厂编号] 
    and [发货表].[订单编号]='" & Trim(Text1(0).Text) & "'
      

  4.   

    update [库存纪录] 
    set [库存纪录].[数量]=[库存纪录].[数量]-(Select [发货表].[数量] from [发货表] where [发货表].[配件编号]=[库存纪录].[配件编号] and [发货表].[原厂编号]=[库存纪录].[原厂编号] ) 
    where [发货表].[配件编号]=[库存纪录].[配件编号] and [发货表].[原厂编号]=[库存纪录].[原厂编号] 
    and [发货表].[订单编号]='" & Trim(Text1(0).Text) & "'