你要加个判断语句进来
Dim str As String
Dim rs As ADODB.Recordset
str = "select sum(inp_money) from input where pur_date>= '" & DTPicker1.Value & "' and pur_date<= '" & DTPicker2.Value & "'"
Set rs = ExecuteSQL(str)
if not rs.eof then
Label4.Caption = rs.Fields(0).Value
else
msgbox "没有相关记录"
end if
Dim str As String
Dim rs As New ADODB.Recordset
str = "select sum(inp_money) from input where pur_date>= '" & DTPicker1.Value & "' and pur_date<= '" & DTPicker2.Value & "'"
Dim str As String
Dim rs As ADODB.Recordset
str = "select sum(isnull(inp_money,0)) from input where pur_date>= '" & DTPicker1.Value & "' and pur_date<= '" & DTPicker2.Value & "'"
Set rs = ExecuteSQL(str)
if not(rs.eof and rs.bof) then
if trim(cstr(rs.fields(0)))<>"" then
Label4.Caption = cstr(rs.Fields(0)).Value
end if
endif
改为:
Dim str As String
Dim rs As new ADODB.Recordset '要new 的
str = "select sum(inp_money) from input where pur_date>= '" & DTPicker1.Value & "' and pur_date<= '" & DTPicker2.Value & "'"
改为:
Dim str As String
Dim rs As new ADODB.Recordset '要new 的
str = "select sum(inp_money) from input where pur_date>= '" & DTPicker1.Value & "' and pur_date<= '" & DTPicker2.Value & "'"
Dim str As String
Dim rs As ADODB.Recordset
str = "select sum(inp_money) from input where pur_date>= '" & DTPicker1.Value & "' and pur_date<= '" & DTPicker2.Value & "'"
Set rs = ExecuteSQL(str)
If not isnull(rs.fields(0)) then
Label4.Caption = rs.Fields(0).Value
endif
Set rs2 = New ADODB.Recordset
strsql = "select * from DATA Where"
rs2.Open strsql, dbcn, adOpenStatic, adLockOptimistic
If rs2.RecordCount > 0 Then
rs2.Fields(0) = data2
rs2.Fields(1)=data1
rs2.Update
Else
With rs2
.AddNew
.Fields(0) = data0
.Fields(1) = data1
.Update
End With
End If