主题:请各位高手给解答疑惑
Dim DBcnn As New ADODB.Connection
Dim DBrs1 As New ADODB.Recordset
Dim DBrs2 As New ADODB.Recordset
Dim sqlstr As String
Private Sub Form_Load()
If DBcnn.State = 0 Then
Dim connectstr As String
connectstr = "Provider=Microsoft.jet.OLEDB.4.0;Data Source=" & _
App.Path & "\KFGL.mdb;Persist Security Info=False"
DBcnn.CursorLocation = adUseClient
DBcnn.Open connectstr
End If
'自动识别数据库路径
' Data1.DatabaseName = App.Path & "\KFGL.MDB"
' Data2.DatabaseName = App.Path & "\KFGL.MDB"
czy.Text = main.StatusBar1.Panels(4).Text
DTP1.Value = Date - 1: DTP2.Value = Date
End Sub
Private Sub Form_Activate()
G1.Text = Left(DTP1, 4) & Right(Left(DTP1, 7), 2) & Right(DTP1, 2) & Left(DTM1, 2) & Left(Right(DTM1, 5), 2)
G2.Text = Left(DTP2, 4) & Right(Left(DTP2, 7), 2) & Right(DTP2, 2) & Left(DTM2, 2) & Left(Right(DTM2, 5), 2)
sqlstr = "select * from tfd "
'Where tfd.BZ > " & Val(G1.Text) &" _
'" AND tfd.BZ<" & Val(G2.Text) & " order by 凭证号码"
If DBrs1.State = 1 Then
DBrs1.Close
End If
DBrs1.Open sqlstr, DBcnn, adOpenDynamic, adLockBatchOptimistic
If DBrs2.State = 1 Then
DBrs2.Close
End If
'统计各项费用
sqlstr = "select count(*)as 数量1,sum(应收宿费)as 应收宿费1," & _
"sum(杂费)as 杂费1,sum(电话费)as 电话费1 ,sum(会议费)as 会议费1," & _
"sum(存车费)as 存车费1,sum(赔偿费)as 赔偿费1,sum(金额总计)as 总计金额1," & _
"sum(预收宿费)as 预收宿费1,sum(退还宿费)as 退还宿费1 from tfd "
'where tfd.BZ >" & _
'Val (G1.Text) & "AND tfd.bz<" & Val(G2.Text)
DBrs2.Open sqlstr, DBcnn, adOpenStatic, adLockBatchOptimistic
' Set MS1.DataSource = DBrs2
'Data1.RecordSource = "select * from tfd where BZ >=" & G1.Text & " AND tfd.BZ<=" & G2.Text & " order by 凭证号码"
'Data1.Refresh
'统计各项费用
' Data2.RecordSource = "select count(*)as 数量1,sum(应收宿费)as 应收宿费1,sum(杂费)as 杂费1,sum(电话费)as 电话费1 ,sum(会议费)as 会议费1,sum(存车费)as 存车费1,sum(赔偿费)as 赔偿费1,sum(金额总计)as 总计金额1,sum(预收宿费)as 预收宿费1,sum(退还宿费)as 退还宿费1 from tfd where tfd.BZ >" & Val(G1.Text) & "AND tfd.bz<" & Val(G2.Text)
' Data2.Refresh
'设置MSFlexgrid的列宽
MS1.colwidth(0) = 0: MS1.colwidth(1) = 1500:[b][color=00FFFF]MS1.colwidth(2) = 700[/color][/b] MS1.colwidth(3) = 0: MS1.colwidth(4) = 0: MS1.colwidth(5) = 0
MS1.colwidth(7) = 600: MS1.colwidth(8) = 0: MS1.colwidth(9) = 450
MS1.colwidth(10) = 0: MS1.colwidth(11) = 0: MS1.colwidth(12) = 450
MS1.colwidth(13) = 0: MS1.colwidth(14) = 840: MS1.colwidth(15) = 450
MS1.colwidth(16) = 900: MS1.colwidth(17) = 450: MS1.colwidth(18) = 780
MS1.colwidth(19) = 780: MS1.colwidth(20) = 780: MS1.colwidth(21) = 780
MS1.colwidth(22) = 780: MS1.colwidth(23) = 780: MS1.colwidth(24) = 780
MS1.colwidth(25) = 0: MS1.colwidth(26) = 0: MS1.colwidth(27) = 0
MS1.colwidth(28) = 0: MS1.colwidth(29) = 0: MS1.colwidth(30) = 0
MS1.colwidth(31) = 0: MS1.colwidth(6) = 0
MS2.colwidth(0) = 4950: MS2.colwidth(1) = 900: MS2.colwidth(2) = 450
MS2.colwidth(3) = 780: MS2.colwidth(4) = 780: MS2.colwidth(5) = 780
MS2.colwidth(6) = 780: MS2.colwidth(7) = 780: MS2.colwidth(8) = 780
MS2.colwidth(9) = 780
'设置下面各列的标题
MS1.TextMatrix(0, 9) = "房价": MS1.TextMatrix(0, 25) = "押金"
MS1.TextMatrix(0, 12) = "天数": MS1.TextMatrix(0, 14) = "结款方式"
MS1.TextMatrix(0, 17) = "杂费": MS1.TextMatrix(0, 22) = "实收金额"
MS2.TextMatrix(0, 0) = "合计"
End Sub
Private Sub Command1_Click()
Form_Activate
End Sub
Private Sub Command2_Click()
main.Enabled = True
Unload Me
End Sub
在调试程序时总是提示:实时错误。。。
我选择调试后箭头指向MS1.colwidth(2) = 700,不知道这个怎么错误,请各位帮忙。
Dim DBrs1 As New ADODB.Recordset
Dim DBrs2 As New ADODB.Recordset
Dim sqlstr As String
Private Sub Form_Load()
If DBcnn.State = 0 Then
Dim connectstr As String
connectstr = "Provider=Microsoft.jet.OLEDB.4.0;Data Source=" & _
App.Path & "\KFGL.mdb;Persist Security Info=False"
DBcnn.CursorLocation = adUseClient
DBcnn.Open connectstr
End If
'自动识别数据库路径
' Data1.DatabaseName = App.Path & "\KFGL.MDB"
' Data2.DatabaseName = App.Path & "\KFGL.MDB"
czy.Text = main.StatusBar1.Panels(4).Text
DTP1.Value = Date - 1: DTP2.Value = Date
End Sub
Private Sub Form_Activate()
G1.Text = Left(DTP1, 4) & Right(Left(DTP1, 7), 2) & Right(DTP1, 2) & Left(DTM1, 2) & Left(Right(DTM1, 5), 2)
G2.Text = Left(DTP2, 4) & Right(Left(DTP2, 7), 2) & Right(DTP2, 2) & Left(DTM2, 2) & Left(Right(DTM2, 5), 2)
sqlstr = "select * from tfd "
'Where tfd.BZ > " & Val(G1.Text) &" _
'" AND tfd.BZ<" & Val(G2.Text) & " order by 凭证号码"
If DBrs1.State = 1 Then
DBrs1.Close
End If
DBrs1.Open sqlstr, DBcnn, adOpenDynamic, adLockBatchOptimistic
If DBrs2.State = 1 Then
DBrs2.Close
End If
'统计各项费用
sqlstr = "select count(*)as 数量1,sum(应收宿费)as 应收宿费1," & _
"sum(杂费)as 杂费1,sum(电话费)as 电话费1 ,sum(会议费)as 会议费1," & _
"sum(存车费)as 存车费1,sum(赔偿费)as 赔偿费1,sum(金额总计)as 总计金额1," & _
"sum(预收宿费)as 预收宿费1,sum(退还宿费)as 退还宿费1 from tfd "
'where tfd.BZ >" & _
'Val (G1.Text) & "AND tfd.bz<" & Val(G2.Text)
DBrs2.Open sqlstr, DBcnn, adOpenStatic, adLockBatchOptimistic
' Set MS1.DataSource = DBrs2
'Data1.RecordSource = "select * from tfd where BZ >=" & G1.Text & " AND tfd.BZ<=" & G2.Text & " order by 凭证号码"
'Data1.Refresh
'统计各项费用
' Data2.RecordSource = "select count(*)as 数量1,sum(应收宿费)as 应收宿费1,sum(杂费)as 杂费1,sum(电话费)as 电话费1 ,sum(会议费)as 会议费1,sum(存车费)as 存车费1,sum(赔偿费)as 赔偿费1,sum(金额总计)as 总计金额1,sum(预收宿费)as 预收宿费1,sum(退还宿费)as 退还宿费1 from tfd where tfd.BZ >" & Val(G1.Text) & "AND tfd.bz<" & Val(G2.Text)
' Data2.Refresh
'设置MSFlexgrid的列宽
MS1.colwidth(0) = 0: MS1.colwidth(1) = 1500:[b][color=00FFFF]MS1.colwidth(2) = 700[/color][/b] MS1.colwidth(3) = 0: MS1.colwidth(4) = 0: MS1.colwidth(5) = 0
MS1.colwidth(7) = 600: MS1.colwidth(8) = 0: MS1.colwidth(9) = 450
MS1.colwidth(10) = 0: MS1.colwidth(11) = 0: MS1.colwidth(12) = 450
MS1.colwidth(13) = 0: MS1.colwidth(14) = 840: MS1.colwidth(15) = 450
MS1.colwidth(16) = 900: MS1.colwidth(17) = 450: MS1.colwidth(18) = 780
MS1.colwidth(19) = 780: MS1.colwidth(20) = 780: MS1.colwidth(21) = 780
MS1.colwidth(22) = 780: MS1.colwidth(23) = 780: MS1.colwidth(24) = 780
MS1.colwidth(25) = 0: MS1.colwidth(26) = 0: MS1.colwidth(27) = 0
MS1.colwidth(28) = 0: MS1.colwidth(29) = 0: MS1.colwidth(30) = 0
MS1.colwidth(31) = 0: MS1.colwidth(6) = 0
MS2.colwidth(0) = 4950: MS2.colwidth(1) = 900: MS2.colwidth(2) = 450
MS2.colwidth(3) = 780: MS2.colwidth(4) = 780: MS2.colwidth(5) = 780
MS2.colwidth(6) = 780: MS2.colwidth(7) = 780: MS2.colwidth(8) = 780
MS2.colwidth(9) = 780
'设置下面各列的标题
MS1.TextMatrix(0, 9) = "房价": MS1.TextMatrix(0, 25) = "押金"
MS1.TextMatrix(0, 12) = "天数": MS1.TextMatrix(0, 14) = "结款方式"
MS1.TextMatrix(0, 17) = "杂费": MS1.TextMatrix(0, 22) = "实收金额"
MS2.TextMatrix(0, 0) = "合计"
End Sub
Private Sub Command1_Click()
Form_Activate
End Sub
Private Sub Command2_Click()
main.Enabled = True
Unload Me
End Sub
在调试程序时总是提示:实时错误。。。
我选择调试后箭头指向MS1.colwidth(2) = 700,不知道这个怎么错误,请各位帮忙。