执行后结果,只不过出现了符合Z(1)=“银行存款”数额的J(1)字段的记录!
但是,这程序好象却没有能够实现循环!!??
执行后结果,只不过出现了符合Z(1)=“银行存款”数额的J(1)字段的记录!
但是,这程序好象却没有能够实现循环!!??
改为:
Private Sub Command1_Click()
Dim jj, ss, ii As Integer
Dim mysql As String
For jj = 1 To 9
mysql = "select * from fl2 where [z(" & jj & ")]='银行存款' "
If Conn.Execute(mysql).EOF = False And IsNull(Conn.Execute(mysql)(0)) = False Then
Set Rst = Conn.Execute(mysql)
End If
ss = Rst.Fields.Count
If Rst.BOF = True Then
MsgBox "no!"
Else
Set DataGrid1.DataSource = Rst
For ii = 0 To ss - 1
DataGrid1.Columns(ii).Alignment = dbgCenter
DataGrid1.Columns(ii).Width = 1000
Next ii
DataGrid1.AllowUpdate = False
End If
Next
End Sub
怎么就显示一个记录呢?
没有实现循环???!!!
依照提示改为如下:
Private Sub Command1_Click()
Dim ii, ss, jj As Integer
Dim mysql As String
For jj = 1 To 9
mysql = "Select [j(" & jj & ")] from fl2 where [z(" & jj & ")]='银行存款' "
If Conn.Execute(mysql).EOF = False And IsNull(Conn.Execute(mysql)(0)) = False Then
Set Rst = Conn.Execute(mysql)
End If
Next jj
If Rst.BOF = True Then
MsgBox "no!"
Else
Set DataGrid1.DataSource = Rst
ss = Rst.Fields.Count = 1
For ii = 0 To ss - 1 = 0
DataGrid1.Columns(ii).Alignment = dbgCenter
DataGrid1.Columns(ii).Width = 1000
Next ii
DataGrid1.AllowUpdate = False
End If
End Sub
但结果仍然照旧!
我想把每个记录中Z(I)字段值=“银行存款”时对应的J(I)或D(I)的值排列输出来!
以前是总计数,代码如下:
For i2 = 1 To 9
s2 = "Select Sum([j(" & i2 & ")]) from fl2 where [z(" & i2 & ")]='银行存款' GROUP BY [Z(" & i2 & ")]"
If conn.Execute(s2).EOF = False And IsNull(conn.Execute(s2)(0)) = False Then
a2 = a2 + conn.Execute(s2)(0)
End If
Next