Dim lSum As Double
With Adodc1
If .Recordset.RecordCount > 0 Then
.Recordset.MoveFirst
Do While Not .Recordset.EOF()
lSum = lSum + Val(Adodc1.Recordset("考核").Value)
'这里还可指定其它字段统计
If Not .Recordset.EOF() Then .Recordset.MoveNext
Loop
End If
Frame3.Caption = "当前自定义查询结果: 考核合计数:" & lSum
End With
DataGrid1.Items[rs.RecordCount + 2].Cells[基层].Texttop = "找到" & rs.RecordCount & "条记录。"此条代码出错,不知道错在哪里?
请求高手帮助!
With Adodc1
If .Recordset.RecordCount > 0 Then
.Recordset.MoveFirst
Do While Not .Recordset.EOF()
lSum = lSum + Val(Adodc1.Recordset("考核").Value)
'这里还可指定其它字段统计
If Not .Recordset.EOF() Then .Recordset.MoveNext
Loop
End If
Frame3.Caption = "当前自定义查询结果: 考核合计数:" & lSum
End With
DataGrid1.Items[rs.RecordCount + 2].Cells[基层].Texttop = "找到" & rs.RecordCount & "条记录。"此条代码出错,不知道错在哪里?
请求高手帮助!
解决方案 »
- 暴暴暴汗!!!!!!!我竟然如此意外地就做爸爸了!!!!!!!!!还好没破财!!大家以后遇到这种事,一定要小心..............
- 算法问题,谁听说过这种算法?高分求解
- 求助,vb菜单编辑器当中的协调位置和帮助上下文ID怎么用?
- 我用以下方法将excel中数据导入到access2000中效率很低,有无解决方法,望高手指点
- [在线等待]紧急:wininet.dll问题
- 新手求教,关于VB6.0中获取域用户名的问题。
- 这么写有什么问题?————问了一下午了
- VB如何编程实现文件夹加密及加锁!文件防止被删除!!500分送上。
- 如何让程序运行时停一下,然后接下去运行?
- 小妹求救!
- VB中MDIFORM窗体问题
- 文件操作问题
DataGrid1.Items[rs.RecordCount + 2].Cells[基层].Texttop = "找到" & rs.RecordCount & "条记录。"
这一句改成
Me.Label1.Caption="找到" & rs.RecordCount & "条记录。"
你的这种需求,换 MSHFlexGrid 可能更灵活。
很不幸,只能告诉你,DataGrid 不是为这种用法设计的。
On Error GoTo errExcel
Dim i As Integer, j As Integer
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim File1, File2 As String
File1 = App.Path & "\报表\!模板报表\!道路交通违法情况表.xls"
File2 = App.Path & "\报表\道路交通违法情况表.xls"
FileCopy File1, File2
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open(File2)
Set xlSheet = xlBook.Worksheets(1)
xlSheet.Cells(4, 1) = "编制单位:" & "*********交通有限公司"
ProgressBar1.Min = 0
ProgressBar1.Max = 22 * 2
ProgressBar1.Visible = True
For i = 1 To DataGrid1.Row - 1
DataGrid1.Row = i
For j = 1 To 22
DataGrid1.Col = j
If IsNull(DataGrid1.Text) = False Then
xlSheet.Cells(i + 5, j) = DataGrid1.Text
End If
Next
Next
xlSheet.Cells(i + 5, 2) = "制单:" & "*****"
xlSheet.Cells(i + 5, 9) = "打印日期:"
xlSheet.Cells(i + 5, 11) = Format(Date, "yyyy-mm-dd")
For i = 2 To DataGrid1.Col - 2
ProgressBar1.Value = ProgressBar1.Value + 1
For j = 1 To 24
xlSheet.Cells(i + 4, j).Select
xlSheet.Cells(i + 4, j).Borders(xlDiagonalDown).LineStyle = xlNone
xlSheet.Cells(i + 4, j).Borders(xlDiagonalUp).LineStyle = xlNone
With xlSheet.Cells(i + 4, j).Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With xlSheet.Cells(i + 4, j).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With xlSheet.Cells(i + 4, j).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With xlSheet.Cells(i + 4, j).Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Next
Next
ProgressBar1.Visible = False
xlApp.Visible = True
xlBook.Save
Exit Sub
errExcel:
If Err.Number = 70 Then
MsgBox "请关闭Excel报表文件,再生成!", vbInformation, "系统提示"
Else
MsgBox Err.Description, vbInformation, "系统出错"
End IfEnd Sub
为什么文件不能拷贝!内容不能输出到execl上