vb ado急!

wuyuchang 2008-03-28 04:27:06
下面的代码为什么执行不出来啊!

Private Function LF_SourceSet() As String
Dim ldatFrom As Date
Dim ldatTo As Date
Dim lstrpart As String
Dim lstrReturn As String
Dim IcmmTemp As New ADODB.Command

lstrReturn = ""

ldatFrom = IIf(IsNull(Me.txtFrom), "1/1/1930", Me.txtFrom)
ldatTo = IIf(IsNull(Me.txtTo), "31/12/2999", Me.txtTo)

Set IcmmTemp.ActiveConnection = CurrentProject.Connection

On Error Resume Next
IcmmTemp.CommandText = "INSERT INTO tbltmpfromdate ([Part #],[Qty] ) " & _
"SELECT [Part #],-[[Quantity]]" & _
"FROM tblStockHistory" & _
"WHERE [Process Date] > ldatFrom" & _
"UNION ALL" & _
"SELECT [Part #],[Total On-Hand]" & _
"FROM tblMasterPart"
IcmmTemp.Execute

IcmmTemp.CommandText = "INSERT INTO tbltmptodate ([Part #],[Qty] ) " & _
"SELECT [Part #],-[[Quantity]]" & _
"FROM tblStockHistory" & _
"WHERE [Process Date] > ldatTo" & _
"UNION ALL" & _
"SELECT [Part #],[Total On-Hand]" & _
"FROM tblMasterPart"
IcmmTemp.Execute

IcmmTemp.CommandText = "INSERT INTO tbltmpchange ([Increase],[Descrease],[Part #] ) " & _
"SELECT [Part #],sum(IIF(tblStockHistory.[Quantity] >= 0,tblStockHistory.[Quantity],0))" & _
",sum(IIF(tblStockHistory.[Quantity] < 0,-tblStockHistory.[Quantity],0))" & _
"FROM tblStockHistory" & _
"WHERE [Process Date] BETWEEN #" & _
Format(ldatFrom, "mm/dd/yyyy") & "# And #" & _
Format(ldatTo, "mm/dd/yyyy") & "#" & _
"GROUP BY [Part #]"
IcmmTemp.Execute

IcmmTemp.CommandText = "INSERT INTO tbltmponhand([Part #],[Qty] ) " & _
"SELECT [Part #],sum(Qty)" & _
"FROM tbltmptodate" & _
"GROUP BY [Part #]"
IcmmTemp.Execute

IcmmTemp.CommandText = "INSERT INTO tbltmplastonhand ([Part #],[Qty] ) " & _
"SELECT [Part #],sum(Qty)" & _
"FROM tbltmpfromdate" & _
"GROUP BY [Part #]"
IcmmTemp.Execute

Set IcmmTemp = Nothing
On Error GoTo 0
...全文
20 点赞 收藏 回复
写回复
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复

还没有回复,快来抢沙发~

相关推荐
发帖
VB基础类
创建于2007-09-28

7490

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2008-03-28 04:27
社区公告
暂无公告