This function takes a several records and appends them together in a single string separated by commas.
Function Attached_Cases(myTicketId As Long) As String
Dim dbs As Database
Dim rst As Recordset
Dim strSQL As String
Dim fld As Field
Dim myLen As Long
Set dbs = CurrentDb()
strSQL = "SELECT dbo_SW_CASE.swCaseId FROM dbo_SW_CASE INNER JOIN dbo_SW_TICKET ON dbo_SW_CASE.dsTicketId = dbo_SW_TICKET.swTicketId WHERE dbo_SW_TICKET.swTicketId = " & myTicketId & ""
Set rst = dbs.OpenRecordset(strSQL)
Set fld = rst!swCaseId
While (Not (rst.EOF))
Attached_Cases = Attached_Cases & fld & ", "
rst.MoveNext
Wend
myLen = Len(Attached_Cases) - 2
'get rid of the last comma
Attached_Cases = Left(Attached_Cases, myLen)
' Close the recordset and the database.
rst.Close
dbs.Close
End Function
Trisha
padinka@yahoo.com
Function Attached_Cases(myTicketId As Long) As String
Dim dbs As Database
Dim rst As Recordset
Dim strSQL As String
Dim fld As Field
Dim myLen As Long
Set dbs = CurrentDb()
strSQL = "SELECT dbo_SW_CASE.swCaseId FROM dbo_SW_CASE INNER JOIN dbo_SW_TICKET ON dbo_SW_CASE.dsTicketId = dbo_SW_TICKET.swTicketId WHERE dbo_SW_TICKET.swTicketId = " & myTicketId & ""
Set rst = dbs.OpenRecordset(strSQL)
Set fld = rst!swCaseId
While (Not (rst.EOF))
Attached_Cases = Attached_Cases & fld & ", "
rst.MoveNext
Wend
myLen = Len(Attached_Cases) - 2
'get rid of the last comma
Attached_Cases = Left(Attached_Cases, myLen)
' Close the recordset and the database.
rst.Close
dbs.Close
End Function
Trisha
padinka@yahoo.com