Private Sub RefreshEx()
On Error GoTo err
MSHFlexGrid1.Clear
With Adodc1
.ConnectionString = CNstr
.CommandTimeout = 15
.RecordSource = "select Goods.G_ID as 商品编号,G_Name as 商品名,DT_Amount as 数量,G_Unit as 单位,G_Spec as 规格,DT_Price as 单价,DT_Bill as 单据号 from Goods,Detail,Billlog where BL_Date='" & Date & "' and BL_RC=1 and BL_IOFlag='入' and DT_Bill =Billlog.BL_ID and DT_GID=G_ID order by Goods.G_ID"
End With
Adodc1.Refresh
Set MSHFlexGrid1.DataSource = Adodc1
MSHFlexGrid1.Refresh
Dim RS As Recordset
Set RS = New ADODB.Recordset
'RS.Open "select sum(DT_Amount*DT_Price) as TheSum from Detail,Billlog where BL_Date='" & Date & "' and BL_RC=1 and BL_IOFlag='入' and DT_Bill =Billlog.BL_ID", CN, adOpenStatic, adLockReadOnly
RS.Open "select sum(DT_Amount*DT_Price) as TheSum from Detail,Billlog where BL_RC=1 and BL_IOFlag='入' and DT_Bill =Billlog.BL_ID", CN, adOpenStatic, adLockReadOnlyIf RS!TheSum > 0 Then
SumUp = RS!TheSum
Else
SumUp = 0
End IfMe.Caption = "当日入库统计 [入库金额共计 ¥" & SumUp & "]"
RS.Close
Exit Sub
err:
MsgBox "有错误发生!", vbCritical, "Error"
End Sub其中这里的Date比较时出错了,去掉以后就没有了:
.RecordSource = "select Goods.G_ID as 商品编号,G_Name as 商品名,DT_Amount as 数量,G_Unit as 单位,G_Spec as 规格,DT_Price as 单价,DT_Bill as 单据号 from Goods,Detail,Billlog where BL_Date='" & Date & "' and BL_RC=1 and BL_IOFlag='入' and DT_Bill =Billlog.BL_ID and DT_GID=G_ID order by Goods.G_ID"
这个在sql2000里就没有错误,我现在用的access.结果就出错了^
On Error GoTo err
MSHFlexGrid1.Clear
With Adodc1
.ConnectionString = CNstr
.CommandTimeout = 15
.RecordSource = "select Goods.G_ID as 商品编号,G_Name as 商品名,DT_Amount as 数量,G_Unit as 单位,G_Spec as 规格,DT_Price as 单价,DT_Bill as 单据号 from Goods,Detail,Billlog where BL_Date='" & Date & "' and BL_RC=1 and BL_IOFlag='入' and DT_Bill =Billlog.BL_ID and DT_GID=G_ID order by Goods.G_ID"
End With
Adodc1.Refresh
Set MSHFlexGrid1.DataSource = Adodc1
MSHFlexGrid1.Refresh
Dim RS As Recordset
Set RS = New ADODB.Recordset
'RS.Open "select sum(DT_Amount*DT_Price) as TheSum from Detail,Billlog where BL_Date='" & Date & "' and BL_RC=1 and BL_IOFlag='入' and DT_Bill =Billlog.BL_ID", CN, adOpenStatic, adLockReadOnly
RS.Open "select sum(DT_Amount*DT_Price) as TheSum from Detail,Billlog where BL_RC=1 and BL_IOFlag='入' and DT_Bill =Billlog.BL_ID", CN, adOpenStatic, adLockReadOnlyIf RS!TheSum > 0 Then
SumUp = RS!TheSum
Else
SumUp = 0
End IfMe.Caption = "当日入库统计 [入库金额共计 ¥" & SumUp & "]"
RS.Close
Exit Sub
err:
MsgBox "有错误发生!", vbCritical, "Error"
End Sub其中这里的Date比较时出错了,去掉以后就没有了:
.RecordSource = "select Goods.G_ID as 商品编号,G_Name as 商品名,DT_Amount as 数量,G_Unit as 单位,G_Spec as 规格,DT_Price as 单价,DT_Bill as 单据号 from Goods,Detail,Billlog where BL_Date='" & Date & "' and BL_RC=1 and BL_IOFlag='入' and DT_Bill =Billlog.BL_ID and DT_GID=G_ID order by Goods.G_ID"
这个在sql2000里就没有错误,我现在用的access.结果就出错了^
BL_Date = #2006-05-01#
BL_Date >= #1996-05-01# and BL_Date <= #2006-05-01#
BL_DateTime = #2006-05-01 13:22:56#而在MSSQL中则同字符串一样,用单引号括起来就可以了,例如:
BL_Date = '2006-05-01'
BL_Date >= '1996-05-01' and BL_Date <= '2006-05-01'
BL_DateTime = '2006-05-01 13:22:56'