Hi BlueDeviledEgg (what is your name?)
for the records you have already created, you will probably want to loop through the table and parse the Children into arrays, then write those values to another table using an Append Query
put this code into a general (standard) module
CODE
Sub ParseChildren()
' CLICK HERE
' press F5 to Run
'NEEDS REFERENCE to Microsoft DAO Library
' Crystal (strive4peace)
'set up Error Handler
On Error GoTo Proc_Err
dim db as dao.database _
, rs as dao.recordset
Dim arrVariable() As String _
, i As Integer _
, strSQL as string
set db = currentdb
set rs = db.OpenRecordset("tblEmployees", dbOpenSnapshot)
do while not rs.eof
if len(trim(nz(rs!Children,""))) > 0 then
arrVariable = Split(rs!Children, ",")
For i = LBound(arrVariable) To UBound(arrVariable)
strSQL = "INSERT INTO [EmpChildren] " _
& " FIELDS (EmployeeID, [ChildNameField]) " _
& " SELECT " & rs!EmployeeID _
& "'" & arrVariable(i) & "';"
currentdb.execute strSQL
Next i
end if
rs.MoveNext
loop
MsgBox "Done"
Proc_Exit:
On Error Resume Next
'close and release object variables if applicable
rs.close
set rs = nothing
set db = nothing
Exit Sub
Proc_Err:
MsgBox Err.Description, , _
"ERROR " & Err.Number _
& " ParseChildren"
Resume Proc_Exit
'if you want to single-step code to find error, CTRL-Break at MsgBox
'then set this to be the next statement
Resume
End Sub
WHERE
EmployeeID is the Primary Key in the Employees table and the Foreign Key in the Employee Children table
ChildNameField is the Name of the field with the Child's name
EmpChildren is the Name of the table with Employee Children
as for your question about displaying names in a comma delimited list once you have separated them, look here:
Return a concatenated list of sub-record values
http://www.mvps.org/access/modules/mdl0004.htmor here:
code: LoopAndCombine
http://www.utteraccess.com/forums/showflat...;Number=1230988**********************************************************
*** How to Create a Standard (General) Module ***
1. from the database window, click on the Module tab
2. click on the NEW command button
3. type (or paste) the code in
once the code is in the module sheet, from the menu, do -->
Debug,Compile
if there are no syntax/reference errors, nothing will appear to happen -- in this case, nothing happening is good <g>
Make sure to give the module a good name when you save it. You can have several procedures (Subs and Functions) in a module, which gives you a way to categorize them ... ie: basic procedures that would be useful in any database; procedures that are specific to a particular database; procedures for converting data; etc
if you are copying and pasting from the forum, you may find that the lines don't break where they are supposed to -- in that case, copy code from the forum to Word, then copy from Word to a module in Access (make sure Word does not wrap lines -- set the font real small and/or put it in landscape)
'~~~~~~~~~ Compile ~~~~~~~~~
Whenever you change code, references, or switch versions, you should always compile before executing.
from the menu in a VBE (module) window: Debug, Compile
fix any errors on the yellow highlighted lines
keep compiling until nothing happens (this is good!)
~~
if you run code without compiling it, you risk corrupting your database
~~~~~ also be sure to use
Option Explicit at the top of each module so variables that are not declared or are misspelled will be picked up