出现错误!
Private Sub Command3_Click()
Dim ListindexX As Integer, LX As String, i1 As String
On Error GoTo errorhandler
'将选定的序列开始、结束年限范围存放在变量i1中
i1 = Combo1(0).Text & ".年份" & ">= " & CInt(Combo1(1).Text) & " And " & Combo1(0).Text & ".年份" & " <= " & CInt(Combo1(2).Text)
Label3(2).Caption = "序列年限:" & Combo1(1).Text & "~" & Combo1(2).Text & "年。需变动,请选择:"
For I = 0 To List1.ListCount - 1 '从列表框list1(1)内所有字段中,选择一个时间序列
If List1.Selected(I) = True Then
ListindexX = I
Exit For
ElseIf List1.SelCount = 0 Then
MsgBox "您未选择时间序列!"
List1.SetFocus
Exit Sub
End If
Next I
LX = List1.List(ListindexX) '将选中的时间序列名存放在变量XL中
Label2(0).Caption = LX '显示选中的时间序列名
On Error GoTo 1
Adodc1.RecordSource = " select " & Combo1(0).Text & ".年份," & LX & " from " & Combo1(0).Text & " where " & i1
On Error GoTo 1
Adodc1.Refresh '刷新数据库记录集
Set DataGrid1.DataSource = Adodc1 '将DataGrid1 控件绑定到Adodc1上
DataGrid1.Caption = "选定的时间序列数据表"
n = Adodc1.Recordset.RecordCount
ReDim MC(1), X(n - 1)
For I = 0 To n - 1
'当前记录的序号位置AbsolutePosition从1开始取值
Adodc1.Recordset.AbsolutePosition = I + 1
X(I) = Adodc1.Recordset.Fields(1).Value
If I = 0 Then MC(1) = Adodc1.Recordset.Fields(1).Name
Next I
'将"年份"字段的开始、结束值分别显示在标签库label2(1)和label2(2)的caption属性中
Adodc1.Recordset.AbsolutePosition = 1 '当前记录的序号位置AbsolutePosition = 1
Label2(1).Caption = Adodc1.Recordset.Fields(0).Value
Adodc1.Recordset.AbsolutePosition = n '当前记录的序号位置AbsolutePosition =n
Label2(2).Caption = Adodc1.Recordset.Fields(0).Value
MsgBox "您选择的时间序列是:" & Label2(0).Caption & "。现在可以按【关闭】按钮,结束查询了。"
1
Exit Sub
errorhandler:
MsgBox (Err.Description)
End Sub
Private Sub Command3_Click()
Dim ListindexX As Integer, LX As String, i1 As String
On Error GoTo errorhandler
'将选定的序列开始、结束年限范围存放在变量i1中
i1 = Combo1(0).Text & ".年份" & ">= " & CInt(Combo1(1).Text) & " And " & Combo1(0).Text & ".年份" & " <= " & CInt(Combo1(2).Text)
Label3(2).Caption = "序列年限:" & Combo1(1).Text & "~" & Combo1(2).Text & "年。需变动,请选择:"
For I = 0 To List1.ListCount - 1 '从列表框list1(1)内所有字段中,选择一个时间序列
If List1.Selected(I) = True Then
ListindexX = I
Exit For
ElseIf List1.SelCount = 0 Then
MsgBox "您未选择时间序列!"
List1.SetFocus
Exit Sub
End If
Next I
LX = List1.List(ListindexX) '将选中的时间序列名存放在变量XL中
Label2(0).Caption = LX '显示选中的时间序列名
On Error GoTo 1
Adodc1.RecordSource = " select " & Combo1(0).Text & ".年份," & LX & " from " & Combo1(0).Text & " where " & i1
On Error GoTo 1
Adodc1.Refresh '刷新数据库记录集
Set DataGrid1.DataSource = Adodc1 '将DataGrid1 控件绑定到Adodc1上
DataGrid1.Caption = "选定的时间序列数据表"
n = Adodc1.Recordset.RecordCount
ReDim MC(1), X(n - 1)
For I = 0 To n - 1
'当前记录的序号位置AbsolutePosition从1开始取值
Adodc1.Recordset.AbsolutePosition = I + 1
X(I) = Adodc1.Recordset.Fields(1).Value
If I = 0 Then MC(1) = Adodc1.Recordset.Fields(1).Name
Next I
'将"年份"字段的开始、结束值分别显示在标签库label2(1)和label2(2)的caption属性中
Adodc1.Recordset.AbsolutePosition = 1 '当前记录的序号位置AbsolutePosition = 1
Label2(1).Caption = Adodc1.Recordset.Fields(0).Value
Adodc1.Recordset.AbsolutePosition = n '当前记录的序号位置AbsolutePosition =n
Label2(2).Caption = Adodc1.Recordset.Fields(0).Value
MsgBox "您选择的时间序列是:" & Label2(0).Caption & "。现在可以按【关闭】按钮,结束查询了。"
1
Exit Sub
errorhandler:
MsgBox (Err.Description)
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货