'On Error GoTo TowardsError
Dim dbs As DAO.Database
Dim rst As DAO.Recordset2
Dim temp
'Get the database, recordset, and attachment field
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT ALLOCATION, AMOUNTs, REMARKS FROM [DEPARTMENT & ALLOCATION] WHERE [CR NO]='" & CRNO & "'")
Do Until rst.EOF
'For each item, get the Allocation and Amount details.
9 temp = temp & rst("ALLOCATION") & " Rs." & rst("AMOUNTs") & " " & rst("REMARKS") & "; "
'MsgBox Temp
' Move to the next order item (if there is one).
15 rst.MoveNext
16 Loop
'MsgBox (Len(temp) - 2)
Stuff([temp], CharIndex('; ', [temp]), Len('; '), '. ')
'Assign value to function
TWARDS = temp
17 rst.Close
18 CurrentDb.Close
Exit Function
TowardsError:
' You only get here if an error occurred.
' Show the error.
21 MsgBox Err.Number
MsgBox Err.Description
End Function
The above code giving error at the stuff function.