Eddie Mason
Registered User.
- Local time
- Today, 16:34
- Joined
- Jan 31, 2003
- Messages
- 142
I have a table with a field ‘Options’ that contains several records. What I want to do is to list the content of ‘Options’ into a single field separated by space.
Eg: Options
Small
Medium
Large
To appear in a field as: Small Medium Large
Options
Small
Medium
Large
Massive
To appear in a field as: Small Medium Large Massive
I have been supplied with the following function, which I have tried but cannot get to work:
Public Function FieldLine(FName As String, TName As String, Separator As String) As String
Dim Mydb As Database
Dim Rst As Recordset
Set Mydb = CurrentDb
Set Rst = Mydb.OpenRecordset("SELECT " & FName & " FROM " & TName & " WHERE FName is Not Null")
FieldLine = ""
While Not Rst.EOF
FieldLine = FieldLine & Rst.Fields(0) & Separator
Wend
If FieldLine <> "" Then
FieldLine = Left(FieldLine, Len(FieldLine) - Len(Separator)) 'to remove last separator
End If
End Function
Can anyone see why this is not working?
Kind regards,
Eddie
Eg: Options
Small
Medium
Large
To appear in a field as: Small Medium Large
Options
Small
Medium
Large
Massive
To appear in a field as: Small Medium Large Massive
I have been supplied with the following function, which I have tried but cannot get to work:
Public Function FieldLine(FName As String, TName As String, Separator As String) As String
Dim Mydb As Database
Dim Rst As Recordset
Set Mydb = CurrentDb
Set Rst = Mydb.OpenRecordset("SELECT " & FName & " FROM " & TName & " WHERE FName is Not Null")
FieldLine = ""
While Not Rst.EOF
FieldLine = FieldLine & Rst.Fields(0) & Separator
Wend
If FieldLine <> "" Then
FieldLine = Left(FieldLine, Len(FieldLine) - Len(Separator)) 'to remove last separator
End If
End Function
Can anyone see why this is not working?
Kind regards,
Eddie