| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 421 人关注过本帖
标题:怎么回事呀?查询不到记录!
只看楼主 加入收藏
dhm899
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-1-7
收藏
 问题点数:0 回复次数:0 
怎么回事呀?查询不到记录!
怎么回事呀?查询不到记录!

使用ADODC控件绑定数据源

以下是数据输出按钮代码:

Dim txt1 As String
Dim i As Integer, j As Integer, k As Integer, l As Integer
Dim myexcel As New Excel.Application
Dim mybook As New Excel.Workbook
Dim mysheet As New Excel.Worksheet
If Check1.Value = True Then
txt1 = "select 日期 from inothermany "
Adodc1.RecordSource = txt1
Adodc1.Refresh
k = Adodc1.Recordset.Fields.count
l = Adodc1.Recordset.RecordCount + 1
Else
If Check1.Value = True And Check2.Value = True Then
txt1 = "select 日期,收入金额 from inothermany "
Adodc1.RecordSource = txt1
Adodc1.Refresh
k = Adodc1.Recordset.Fields.count
l = Adodc1.Recordset.RecordCount + 1
Else
If Check1.Value = True And Check2.Value = True And Check3.Value = True Then
txt1 = "select 日期,收入金额,来源方式 from inothermany"
Adodc1.RecordSource = txt1
Adodc1.Refresh
k = Adodc1.Recordset.Fields.count
l = Adodc1.Recordset.RecordCount + 1
Else
If Check1.Value = True And Check2.Value = True And Check3.Value = True And Check4.Value = True Then
txt1 = "select 日期,收入金额,来源方式,备注 from inothermany"
Adodc1.RecordSource = txt1
Adodc1.Refresh
k = Adodc1.Recordset.Fields.count
l = Adodc1.Recordset.RecordCount + 1
End If
End If
End If
End If

If l > 1 Then
Set mybook = myexcel.Workbooks.Add '添加一个新的BOOK
Set mysheet = mybook.Worksheets(1) 'worksheets(1),意思是直接输出到工作表1中
For j = 1 To k
mysheet.Cells(1, j) = Adodc1.Recordset.Fields.Item(j - 1).Name
Next j
For i = 2 To l
For j = 1 To Adodc1.Recordset.Fields.count
If Not Adodc1.Recordset.EOF Then
On Error GoTo err02
mysheet.Cells(i, j) = Adodc1.Recordset.Fields.Item(j - 1).Value
If (i * j) Mod 500 = 0 Then
DoEvents
End If
Else
Exit Sub
End If
Next j
Adodc1.Recordset.MoveNext
Next i
myexcel.Visible = True
mybook.SaveAs ("其它收入数据") '保存文件 并输出文件名为many
'Set myexcel = Nothing '交还控制给EXCEL
'Set mybook = Nothing
'Set mysheet = Nothing
'mybook.Close
'myexcel.Quit
Else
MsgBox "查询不到记录!", vbOKOnly, "友情提示"
Exit Sub
End If
err02:
Exit Sub


搜索更多相关主题的帖子: 记录 查询 
2006-01-20 16:51
快速回复:怎么回事呀?查询不到记录!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.041753 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved