Let me fix that for you so it's not just a wall of un-formatted text;
Code:
Public Function InsertIntoMultiField() '<<compile error:"expected:end of statement"
Dim db As DAO.Database
' ************************************************** *********************
' Main recordset containing both a multi-value field and string field
' ************************************************** *********************
Dim rsENTRY As DAO.Recordset2
' ************************************************** *********************
' Now Define the Multi-Value Fields as a RecordSet
' ************************************************** *********************
Dim rsCLASSNUMBER As DAO.Recordset2
' ************************************************** *********************
' The Values of the Field Are Contained in a Field Object
' Dim fldCLASSNUMBERTemp As DAO.Field2
' ************************************************** *********************
Dim fldCLASSNUMBER As DAO.Field2
Dim I As Integer
' ************************************************** *********************
' Open the Parent File
' ************************************************** *********************
Set db = CurrentDb()
Set rsENTRY = db.OpenRecordset("ENTRY")
' ************************************************** *********************
' Set The Multi-Value Field
' ************************************************** *********************
Set fldCLASSNUMBER = rsENTRY("CLASSNUMBER") '<< error 13;compile error:"expected:end of statement"
' ************************************************** *********************
' Check to Make Sure it is Multi-Value
' ************************************************** *********************
If Not (fldCLASSNUMBER.IsComplex) Then
MsgBox ("Not A Multi-Value Field")
rsENTRY.Close
Set rsENTRY = Nothing
Set fldCLASSNUMBER = Nothing
Exit Function
Else
'MsgBox ("Selected field IS a multi-value field")
End If
On Error Resume Next
' ************************************************** *********************
' Loop Through
' ************************************************** *********************
Do While Not rsENTRY.EOF
' ************************************************** *********************
' Parse Regular Text Field into Array For Insertion into Multi-Value
' ************************************************** *********************
strInputString = rsENTRY!Stringfield
Call ParseInputString
' ************************************************** *********************
' If Entries Are Present, Add Them To The Multi-Value Field
' ************************************************** *********************
If intNumberOfArrayEntries > 0 Then
Set rsCLASSNUMBER = fldCLASSNUMBER.Value
rsENTRY.Edit
For I = 1 To intNumberOfArrayEntries
rsCLASSNUMBER.AddNew
rsCLASSNUMBER("Value") = strStateArray(I)
rsCLASSNUMBER.Update
Next I
rsCLASSNUMBER.Close
rsENTRY.Update
End If
rsENTRY.MoveNext
Loop
On Error GoTo 0
rsENTRY.Close
Set rsENTRY = Nothing
Set rsCLASSNUMBER = Nothing
End Function
Function 2
Code:
Public Function ParseInputString()
Dim intLength As Integer
Dim intStartSearch As Integer
Dim intNextComma As Integer
Dim intStartOfItem As Integer
Dim intLengthOfItem As Integer
Dim strComma As String
strComma = ","
intNumberOfArrayEntries = 0
strInputString = Trim(strInputString)
intLength = Len(strInputString)
' ************************************************** *********************
' Skip Zero Length Strings
' ************************************************** *********************
If intLength = 0 Then
Exit Function
End If
' ************************************************** *********************
' Strip Any Leading Comma
' ************************************************** *********************
If Mid(strInputString, 1, 1) = "," Then
Mid(strInputString, 1, 1) = " "
strInputString = Trim(strInputString)
intLength = Len(strInputString)
If intLength = 0 Then
Exit Function
End If
End If
' ************************************************** *********************
' Strip Any Trailing Comma
' ************************************************** *********************
If Mid(strInputString, intLength, 1) = "," Then
Mid(strInputString, intLength, 1) = " "
strInputString = Trim(strInputString)
intLength = Len(strInputString)
If intLength = 0 Then
Exit Function
End If
End If
intStartSearch = 1
' ************************************************** *********************
' Loop Through And Parse All the Items
' ************************************************** *********************
Do
intNextComma = InStr(intStartSearch, strInputString, strComma)
If intNextComma <> 0 Then
intNumberOfArrayEntries = intNumberOfArrayEntries + 1
intStartOfItem = intStartSearch
intLengthOfItem = intNextComma - intStartOfItem
strStateArray(intNumberOfArrayEntries) = Trim(Mid(strInputString, intStartOfItem, intLengthOfItem))
intStartSearch = intNextComma + 1
Else
intNumberOfArrayEntries = intNumberOfArrayEntries + 1
intStartOfItem = intStartSearch
intLengthOfItem = intLength - intStartSearch + 1
strStateArray(intNumberOfArrayEntries) = Trim(Mid(strInputString, intStartOfItem, intLengthOfItem))
End If
Loop Until intNextComma = 0
End Function
Your error is probably because you either need to use
Set fldCLASSNUMBER = rsENTRY.Fields("CLASSNUMBER")
Or
Set fldCLASSNUMBER = rsENTRY!CLASSNUMBER
Not a syntax halfway between the two ?