|
字段中有若干人名,每人用空格分开,且顺序不固定。如何统计所有记录中每个人名出现次数 ?
如:下面字符分别代表汉字人名(两字或三字不等),人数不固定,之间有空格。
第一个记录 A B F Q
第二个记录 ...
boczsg 发表于 2009-12-18 14:54
Private Sub Form_Close()
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE * FROM 表2;"
End Sub
Private Sub 统计_Click()
Dim rs1 As New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
Dim sql As String
Dim B As String
Dim i As Long
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE * FROM 表2;"
sql = "select * from 表1"
rs1.Open sql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
rs2.Open "表2", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
For i = 1 To rs1.RecordCount
B = rs1("人员")
Do While Nz(B, "") <> ""
rs2.AddNew
If InStr(B, " ") > 0 Then
rs2("姓名") = Mid(B, 1, InStr(B, " ") - 1)
B = Mid(B, InStr(B, " ") + 1)
Else
If InStr(B, " ") = 0 Then
rs2("姓名") = B
B = ""
End If
End If
rs2.Update
Loop
rs1.MoveNext
Next
rs1.Close
rs2.Close
Me.列表.Requery
End Sub
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|