K
Kate
I have a field ([otherstaff]) in a table (tblCompanies]),
containing 0 to several staff names, separated by a comma.
I'm trying to create a query which will display all of the
individual names, but in one column, not as many as there
are names per field.
For example, if a record contains "May Jones, John Way,
Steve Bright" I would like to have the resulting query show:
May Jones
John Way
Steve Bright
in separate rows.
I've created the following code using the Split function,
but it only seems to return the first name in a field. I'm
wondering if there's a way to have it return all the names.
I'm calling the function in a query such as this:
SELECT DISTINCTROW splitstaff([otherstaff]) AS Who
FROM tblCompanies
WHERE (((tblCompanies.OtherStaff) Is Not Null And
(tblCompanies.OtherStaff)<>""));
This is the splitstaff function:
Public Function splitStaff(strFld As String)
'creates an array of names of other staff, parsed out of the
'otherstaff' field in tblcompanies
'used in the query 'otherstaff' as a function
Dim strParse() As String, strValue As String
Dim k As Integer
On Error Resume Next
strParse = Split(strFld, ",")
For k = 0 To UBound(strParse)
splitStaff = LTrim(strParse(k))
Next k
End Function
containing 0 to several staff names, separated by a comma.
I'm trying to create a query which will display all of the
individual names, but in one column, not as many as there
are names per field.
For example, if a record contains "May Jones, John Way,
Steve Bright" I would like to have the resulting query show:
May Jones
John Way
Steve Bright
in separate rows.
I've created the following code using the Split function,
but it only seems to return the first name in a field. I'm
wondering if there's a way to have it return all the names.
I'm calling the function in a query such as this:
SELECT DISTINCTROW splitstaff([otherstaff]) AS Who
FROM tblCompanies
WHERE (((tblCompanies.OtherStaff) Is Not Null And
(tblCompanies.OtherStaff)<>""));
This is the splitstaff function:
Public Function splitStaff(strFld As String)
'creates an array of names of other staff, parsed out of the
'otherstaff' field in tblcompanies
'used in the query 'otherstaff' as a function
Dim strParse() As String, strValue As String
Dim k As Integer
On Error Resume Next
strParse = Split(strFld, ",")
For k = 0 To UBound(strParse)
splitStaff = LTrim(strParse(k))
Next k
End Function