Office中国论坛/Access中国论坛

标题: 【已OK】这个更新代码太长,VBA中录入出错,请问怎样处理? [打印本页]

作者: 真主    时间: 2009-11-18 15:40
标题: 【已OK】这个更新代码太长,VBA中录入出错,请问怎样处理?
本帖最后由 真主 于 2009-11-18 16:05 编辑
  1. DoCmd.RunSQL "INSERT INTO A_JA_003日报录入_主表 ( 日期, 制单帐号, 所属设备ID, 锁定, 制单日志, 日报录入主表编号,开工时间, 班别, 人员01, 人员02, 人员03, 人员04, 人员05, 人员06, 人员07, 人员08, 人员09, 人员10 ) SELECT Format([Forms]![C_JA_003日报录入_电子_主表]![Text_日期],'YYYY-MM-DD') AS 日期A, [Forms]![C_JA_003日报录入_电子_主表]![ctNameID] AS 制单帐号A, [Forms]![C_JA_003日报录入_电子_主表]![Text_机台记号] AS 所属设备IDA, -1 AS 锁定A, DLookUp('UserName','B_AA_UserList','ctNameID = NameID ') & '/' & Now() AS 制单日志A, Format([Forms]![C_JA_003日报录入_电子_主表]![Text_机台记号],'0000') & '_' & Format([Forms]![C_JA_003日报录入_电子_主表]![Text_日期],'YYYYMMDD') AS 日报录入主表编号A, time() AS 开工时间A, IIf(Time()>#12/30/1899 7:30:0# And Time()<#12/30/1899 21:0:0#,1,2) AS 班别, DFirst('姓名','B_JA_000当日当班人员01') AS 人员01, DFirst('姓名','B_JA_000当日当班人员02') AS 人员02, DFirst('姓名','B_JA_000当日当班人员03') AS 人员03, DFirst('姓名','B_JA_000当日当班人员04') AS 人员04, DFirst('姓名','B_JA_000当日当班人员05') AS 人员05, DFirst('姓名','B_JA_000当日当班人员06') AS 人员06, DFirst('姓名','B_JA_000当日当班人员07') AS 人员07, DFirst('姓名','B_JA_000当日当班人员08') AS 人员08, DFirst('姓名','B_JA_000当日当班人员09') AS 人员09, DFirst('姓名','B_JA_000当日当班人员10') AS 人员10"
复制代码



  1.         STemp = "INSERT INTO A_JA_003日报录入_主表"
  2.         STemp = STemp & "( 日期, 制单帐号, 所属设备ID, 锁定, 制单日志, 日报录入主表编号,开工时间, 班别, 人员01, 人员02, 人员03, 人员04, 人员05, 人员06, 人员07, 人员08, 人员09, 人员10 )"
  3.         STemp = STemp & " SELECT Format([Forms]![C_JA_003日报录入_电子_主表]![Text_日期],'YYYY-MM-DD') AS 日期A,"
  4.         STemp = STemp & "[Forms]![C_JA_003日报录入_电子_主表]![ctNameID] AS 制单帐号A,"
  5.         STemp = STemp & "[Forms]![C_JA_003日报录入_电子_主表]![Text_机台记号] AS 所属设备IDA,"
  6.         STemp = STemp & "-1 AS 锁定A,"
  7.         STemp = STemp & "DLookUp('UserName','B_AA_UserList','ctNameID = NameID ') & '/' & Now() AS 制单日志A,"
  8.         STemp = STemp & "Format([Forms]![C_JA_003日报录入_电子_主表]![Text_机台记号],'0000') & '_' & Format([Forms]![C_JA_003日报录入_电子_主表]![Text_日期],'YYYYMMDD') AS 日报录入主表编号A,"
  9.         STemp = STemp & "time() AS 开工时间A,"
  10.         STemp = STemp & "IIf(Time()>#12/30/1899 7:30:0# And Time()<#12/30/1899 21:0:0#,1,2) AS 班别,"
  11.         STemp = STemp & "DFirst('姓名','B_JA_000当日当班人员01') AS 人员01,"
  12.         STemp = STemp & "DFirst('姓名','B_JA_000当日当班人员02') AS 人员02,"
  13.         STemp = STemp & "DFirst('姓名','B_JA_000当日当班人员03') AS 人员03,"
  14.         STemp = STemp & "DFirst('姓名','B_JA_000当日当班人员04') AS 人员04,"
  15.         STemp = STemp & "DFirst('姓名','B_JA_000当日当班人员05') AS 人员05,"
  16.         STemp = STemp & "DFirst('姓名','B_JA_000当日当班人员06') AS 人员06,"
  17.         STemp = STemp & "DFirst('姓名','B_JA_000当日当班人员07') AS 人员07,"
  18.         STemp = STemp & "DFirst('姓名','B_JA_000当日当班人员08') AS 人员08,"
  19.         STemp = STemp & "DFirst('姓名','B_JA_000当日当班人员09') AS 人员09,"
  20.         STemp = STemp & "DFirst('姓名','B_JA_000当日当班人员10') AS 人员10"
  21.         DoCmd.RunSQL STemp
复制代码





欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3