程序代码:Dim SS As Integer
Private Sub Command1_Click()
Adodc1.RecordSource = "Select * From my_接种单" '连接数据表
Adodc1.Refresh
For I = 1 To SS 'SS是 MSFlexGrid1 控件的记录数
Adodc1.Recordset.AddNew
For J = 1 To 5
Adodc1.Recordset.Fields(J) = MSFlexGrid1.TextMatrix(I, J - 1)
Next J
Adodc1.Recordset.Update
Next I
Dim MM As Integer
Adodc1.RecordSource = "Select * From my_接种单" '连接数据表
Adodc1.Refresh
MM = Adodc1.Recordset.RecordCount '得到数据表的记录数
With MSFlexGrid2
.Cols = 5
.Rows = 1 + MM
.TextMatrix(0, 0) = "A"
.TextMatrix(0, 1) = "B"
.TextMatrix(0, 2) = "C"
.TextMatrix(0, 3) = "D"
.TextMatrix(0, 4) = "E"
For I = 1 To MM
For J = 1 To 5
.TextMatrix(I, J - 1) = Adodc1.Recordset.Fields(J)
Next J
Adodc1.Recordset.MoveNext
Next I
End With
MSFlexGrid2.Visible = True
Label1(1).Visible = True
End Sub
Private Sub Form_Load()
'这个仅仅给你提供一个例子,数据表的字段我乱设置的, MSFlexGrid1 控件中的数据也是胡乱设置的
SS = 5
With MSFlexGrid1
.Cols = 5
.Rows = 1 + SS
.TextMatrix(0, 0) = "A"
.TextMatrix(0, 1) = "B"
.TextMatrix(0, 2) = "C"
.TextMatrix(0, 3) = "D"
.TextMatrix(0, 4) = "E"
For I = 1 To SS
.TextMatrix(I, 0) = "A" & I
.TextMatrix(I, 1) = "B" & 2 * I
.TextMatrix(I, 2) = "C" & 3 * I
.TextMatrix(I, 3) = "D" & 4 * I
.TextMatrix(I, 4) = "E" & 5 * I
Next I
End With
MSFlexGrid2.Visible = False
Label1(1).Visible = False
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data.mdb;Persist Security Info=False"
End Sub[此贴子已经被作者于2016-5-23 22:48编辑过]
