Okay... well my first question is what are you doing exactly with the value NameString returns?
I ask because under nearly every circumstance (that I can think of) it is extremely inefficient both in memory usage and time to load a string up like that and then manipulate it later. I can most likely give you an answer that both fixes your problem and allows for a more efficient program. I also noted you do not have an error handler for this function --- with VB and thus VBA this is not a good thing. To give you an example I added one to your function below. ErrorLog would simply be a public function that displays a window message and/or writes the error out (perferably with a datetime stamp) to a log file. This will help greatly in debugging and error checking thus speeding up maintenance and enhancments. Other than that the code looks pretty good. --- myhnews <[EMAIL PROTECTED]> wrote: > I used the function bellow for about 2 years > and never had a problem until I got to a > point where this function combined about 9 > people and reached more then 255 characters, > and report does not display all names. > > Your help is very appreciated. > > Thank you > > Function NameString(RecordID As Variant, > TableName As String, > FieldName As String) As String > > Dim db As DAO.Database > Dim rs As DAO.Recordset > Dim strSQL As String > Dim AssignmentID As Long > Dim FirstName As String > Dim MiddleName As String > Dim LastName As String > Dim Suffix As String > Dim Add As String > Dim NameList As String > On Error Goto ErrorHandler > NameList = "" > > RecordID = Nz(RecordID, 0) > > strSQL = "SELECT * FROM [" > strSQL = strSQL & TableName > strSQL = strSQL & "] WHERE [" > strSQL = strSQL & FieldName & "] = " > strSQL = strSQL & RecordID & ";" > Set db = CurrentDb > Set rs = db.OpenRecordset(strSQL) > > If rs.RecordCount > 0 Then > Do While Not rs.EOF '<< > ' NameList = "" > FirstName = Nz(rs(1) + " ", "") > MiddleName = Nz(rs(2) + " ", "") > LastName = Nz(rs(3) + " ", "") > Suffix = Nz(rs(4) + " ", "") > Add = Nz(rs(5) + " ", "") > > NameList = NameList & FirstName > NameList = NameList & MiddleName > NameList = NameList & LastName > NameList = NameList & Suffix > NameList = NameList & Add & " " > ' NameList = Trim(NameList) > rs.MoveNext > Loop > End If > > NameString = NameList > Exit Function > ' > ErrorHandler: > Call ErrorLog(Err.Message, _ > Err.Number, _ > "ModName.NameString") > End Function > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/AccessVBACentral/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/AccessVBACentral/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
