鼠标的问题不可能。 现贴上代码,大家看看。首先是一个toolbar的click过程: Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) If Button.Key = "CLOSE" Then Unload Me ElseIf Button.Key = "SAVE" Then '保存月票信息前 检查 If Not (checkOK) Then Exit Sub '保存月票信息 lbts.Caption = "正在保存信息" Toolbar1.Buttons(1).Enabled = False If Not (saveinfo) Then Exit Sub '打印发票 lbts.Caption = "正在打印发票" MsgBox " 提示:请将通行证放入打印机,点‘是’打印通行证。 ", vbInformation + vbOKOnly funPrnTxz ("1") MsgBox " 提示:请检查发票打印机是否准备就绪,点‘是’后进行打印。 ", vbInformation + vbOKOnly If funPrnBill = 1 Then lbts.Caption = "保存成功,点‘清除’可清除当前显示信息" Else lbts.Caption = "打印收据失败。" End If cmdFalse.Enabled = False ElseIf Button.Key = "CLEAR" Then txtCH.Text = "" clearinfo End If End Sub 这是出问题的那个打印函数: Private Function funPrnTxz(cls As String) Dim p As New clsSetPrinter Dim rsss As New ADODB.Recordset If cls = "1" Then If Not gPrint打印机是否存在("通行证打印机") Then MsgBox "未安装相应的打印机(" & "通行证打印机" & ")!", vbInformation + vbOKOnly Exit Function End If p.pro设置默认打印机 "通行证打印机" p.pro设置成纵向 Set p = Nothing If rsss.State = adStateOpen Then rsss.Close rsss.Open "select 1 from tbPayrec ", cnSql, adOpenKeyset, adLockReadOnly, adCmdText Set rptTXZ.DataSource = rsss ' rptTXZ.Sections("section2").Controls("lbNo1").Caption = txtNo.Text ' rptTXZ.Sections("section2").Controls("lbNo2").Caption = txtNo.Text rptTXZ.Sections("section2").Controls("lbcar1").Caption = cmbQZ.Text & "-" & txtCH.Text rptTXZ.Sections("section2").Controls("lbcar2").Caption = cmbQZ.Text & "-" & txtCH.Text rptTXZ.Sections("section2").Controls("lby").Caption = Right(txtYear.Text, 1) rptTXZ.Sections("section2").Controls("lbm").Caption = txtMonth.Text rptTXZ.Sections("section2").Controls("lbje1").Caption = txtJE.Text 'rptTXZ.Sections("section2").Controls("lbje2").Caption = txtJE.Text rptTXZ.Sections("section2").Controls("lbdw").Caption = txtDW.Text rptTXZ.Sections("section2").Controls("lbdzw").Caption = txtDzW.Text rptTXZ.Sections("section2").Controls("lbcx").Caption = cmbCX.Text rptTXZ.PrintReport Unload rptTXZ End If End Function
我首先从装了应用程序。--不行
我再从装了打印机驱动。--不行
我又换了台打印机。 --不行
我从装了win98。 --不行
我又装上了win2000. --不行
我跟踪程序。 --不行我还测试过打印别的东西。只有一次结果。
我还装上了杀毒软件。 金山毒霸。2005-3的病毒库。没有病毒。我还可以怎么测试呢?
并且此程序客户已经用了2个多月没问题的。
现贴上代码,大家看看。首先是一个toolbar的click过程:
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
If Button.Key = "CLOSE" Then
Unload Me
ElseIf Button.Key = "SAVE" Then
'保存月票信息前 检查
If Not (checkOK) Then Exit Sub
'保存月票信息
lbts.Caption = "正在保存信息"
Toolbar1.Buttons(1).Enabled = False
If Not (saveinfo) Then Exit Sub
'打印发票
lbts.Caption = "正在打印发票"
MsgBox " 提示:请将通行证放入打印机,点‘是’打印通行证。 ", vbInformation + vbOKOnly
funPrnTxz ("1")
MsgBox " 提示:请检查发票打印机是否准备就绪,点‘是’后进行打印。 ", vbInformation + vbOKOnly
If funPrnBill = 1 Then
lbts.Caption = "保存成功,点‘清除’可清除当前显示信息"
Else
lbts.Caption = "打印收据失败。"
End If
cmdFalse.Enabled = False
ElseIf Button.Key = "CLEAR" Then
txtCH.Text = ""
clearinfo
End If
End Sub
这是出问题的那个打印函数:
Private Function funPrnTxz(cls As String)
Dim p As New clsSetPrinter
Dim rsss As New ADODB.Recordset
If cls = "1" Then
If Not gPrint打印机是否存在("通行证打印机") Then
MsgBox "未安装相应的打印机(" & "通行证打印机" & ")!", vbInformation + vbOKOnly
Exit Function
End If
p.pro设置默认打印机 "通行证打印机"
p.pro设置成纵向
Set p = Nothing
If rsss.State = adStateOpen Then rsss.Close
rsss.Open "select 1 from tbPayrec ", cnSql, adOpenKeyset, adLockReadOnly, adCmdText
Set rptTXZ.DataSource = rsss
' rptTXZ.Sections("section2").Controls("lbNo1").Caption = txtNo.Text
' rptTXZ.Sections("section2").Controls("lbNo2").Caption = txtNo.Text
rptTXZ.Sections("section2").Controls("lbcar1").Caption = cmbQZ.Text & "-" & txtCH.Text
rptTXZ.Sections("section2").Controls("lbcar2").Caption = cmbQZ.Text & "-" & txtCH.Text
rptTXZ.Sections("section2").Controls("lby").Caption = Right(txtYear.Text, 1)
rptTXZ.Sections("section2").Controls("lbm").Caption = txtMonth.Text
rptTXZ.Sections("section2").Controls("lbje1").Caption = txtJE.Text
'rptTXZ.Sections("section2").Controls("lbje2").Caption = txtJE.Text
rptTXZ.Sections("section2").Controls("lbdw").Caption = txtDW.Text
rptTXZ.Sections("section2").Controls("lbdzw").Caption = txtDzW.Text
rptTXZ.Sections("section2").Controls("lbcx").Caption = cmbCX.Text
rptTXZ.PrintReport
Unload rptTXZ
End If
End Function
不过,还有一种可能,就是数据表里的数据不对了!可能存在有两条相同的数据(打印部分),因为你的SQl语句并没有指定返回一条记录,可以修改这个SQL语句让他只返回一条。顺便问一下,clsSetPrinter是vb自己的对象吗
跟踪的时候没这个错误。这是为什么呢?