這應該讓你開始。它會將多選字段中選中的所有值轉換爲它們自己的表格。事實之後,您需要建立三個表格之間的關係以創建真正的多對多關係。
Sub ExtractMultiValueFields()
Dim JoinTable As New DAO.TableDef
JoinTable.Name = "JoinTable"
With JoinTable
.Fields.Append .CreateField("MainTableId", dbInteger)
.Fields.Append .CreateField("JoinToValue", dbText)
End With
Dim joinRs As DAO.Recordset
CurrentDb.TableDefs.Append JoinTable
Set joinRs = CurrentDb.OpenRecordset("JoinTable")
Dim rs As DAO.Recordset
Dim childrs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("select * from table1")
Do While Not rs.EOF
Debug.Print rs("ID")
Set childrs = rs("col1").Value
Do While Not childrs.EOF
Debug.Print childrs("value") 'always "value"
joinRs.AddNew
joinRs("MainTableId") = rs("ID")
joinRs("JoinToValue") = childrs("value")
joinRs.Update
childrs.MoveNext
Loop
rs.MoveNext
Loop
End Sub
多值字段用於與Sharepoint兼容。您可能必須將它們轉換爲1到多個表結構。 – Brad
你好布拉德, 謝謝你的迴應。你會說什麼是轉換它們的最好方法? – LarrySteeze
http://msdn.microsoft.com/en-us/library/office/ff821054%28v=office.15%29.aspx – Brad