Can this be done with a listbox?

papic1972

Registered User.
Local time
Tomorrow, 07:02
Joined
Apr 14, 2004
Messages
122
Hi all,

I've attached 2 attachments to this thread, the 1st attachment 'ListBox1Normal' shows a normal listbox with one record displayed per row.

Is it possible to show the same records but all on one row & separated by a delimiter, as per the 2nd attachment 'ListBox1Proposed'?

:confused:
 

Attachments

  • ListBox1Normal.JPG
    ListBox1Normal.JPG
    4.7 KB · Views: 116
  • ListBox1Proposed.JPG
    ListBox1Proposed.JPG
    6.6 KB · Views: 103
Hi John Big Booty,

I hope i haven't confused you!! How can i elaborate this further?
 
What are you trying to achieve by having all the records displayed in one row? Knowing this will help suggest an appropriate solution.
 
I have a form that has about 40 list boxes on it (i am devising a truck allocation database for a transport company) and i need to show the individual delivery drop suburbs for each truck on the one form. The form will be used as a summary form so the transport allocator can use it to quickly view each truck load.
 
Just so I've got this straight.

Each of the list boxes represents a truck?

Each list box shows the various suburbs that that truck will visit during it's daily run?

You want to consolidate the various suburbs on each trucks daily run into one record for display purposes?
 
Can anyone help me with this. I followed the link as suggested by John Big Booty which lead me to finding a function for concatenating field values (i am using an access 2003 frontend linked to SQL Server 2000 backend): The function is:

Public Function ConcatRelated(strField As String, _
strTable As String, _
Optional strWhere As String, _
Optional strOrderBy As String, _
Optional strSeparator = ", ") As Variant
On Error GoTo Err_Handler

Dim rs As DAO.Recordset 'Related records
Dim rsMV As DAO.Recordset 'Multi-valued field recordset
Dim strSql As String 'SQL statement
Dim strOut As String 'Output string to concatenate to.
Dim lngLen As Long 'Length of string.
Dim bIsMultiValue As Boolean 'Flag if strField is a multi-valued field.



'Initialize to Null
ConcatRelated = Null

'Build SQL string, and get the records.
strSql = "SELECT " & strField & " FROM " & strTable


If strWhere <> vbNullString Then
strSql = strSql & " WHERE " & strWhere

End If
If strOrderBy <> vbNullString Then
strSql = strSql & " ORDER BY " & strOrderBy

End If
Set rs = DBEngine(0)(0).OpenRecordset(strSql, dbOpenDynaset)
'Determine if the requested field is multi-valued (Type is above 100.)
bIsMultiValue = (rs(0).Type > 100)

'Loop through the matching records
Do While Not rs.EOF
If bIsMultiValue Then
'For multi-valued field, loop through the values
Set rsMV = rs(0).Value
Do While Not rsMV.EOF
If Not IsNull(rsMV(0)) Then
strOut = strOut & rsMV(0) & strSeparator
End If
rsMV.MoveNext
Loop
Set rsMV = Nothing
ElseIf Not IsNull(rs(0)) Then
strOut = strOut & rs(0) & strSeparator
End If
rs.MoveNext
Loop
rs.Close

'Return the string without the trailing separator.
lngLen = Len(strOut) - Len(strSeparator)
If lngLen > 0 Then
ConcatRelated = Left(strOut, lngLen)
End If

Exit_Handler:
'Clean up
Set rsMV = Nothing
Set rs = Nothing
Exit Function

Err_Handler:
MsgBox "Error " & Err.Number & ": " & Err.Description, vbExclamation, "ConcatRelated()"
Resume Exit_Handler
End Function


I have tried calling the function from a textbox control source on my form, using the following syntax:

=ConcatRelated("Suburb","aaqryTEST","LoadLineID = " & [LoadLineID])

where aaqryTEST has the following SQL:

SELECT tblLocal.LoadLineID, tblLocal.Suburb, tblLocal.JDNo, tblLocal.DeliveryDate
FROM tblLocal
WHERE (((tblLocal.JDNo)=[Forms]![TruckNo1]![lbl1]) AND ((tblLocal.DeliveryDate)=[Forms]![frmLoadAllocationScreen]![cboAllocationDate]));

When i run the query i keep getting the following error:

ERROR 3061: Too few parameters. Expected 2


I understand that the function is not passing the values of lbl1 & cboAllocationDate from my forms to aaqryTEST, can anyone help me in the right direction with this?
 
I've also tried doing this on a report without success. Has anyone else ever tried this before?
 

Users who are viewing this thread

Back
Top Bottom