Listbox show details

M

mscertified

I have a listbox which shows a small subset of the columns in each record.
I'd like some way to allow the user to point to a row and see the whole
details in some kind of popup window which changes as I point to different
rows. If I could get the controltiptext to do it, that would be great. Is
there a way?
 
S

Stuart McCall

mscertified said:
I have a listbox which shows a small subset of the columns in each record.
I'd like some way to allow the user to point to a row and see the whole
details in some kind of popup window which changes as I point to different
rows. If I could get the controltiptext to do it, that would be great. Is
there a way?

Let's say you're displaying columns 0 and 1 in a listbox called List0 and
you want to pop up columns 2, 3 and 4. Put the following code in List0's
Click event:

With Me.List0
.ControlTipText = .Column(2) & ", " & .Column(3) & ", " & .Column(4)
End With

You can then click on a row, leave the mousepointer there for a second, and
the hidden column data is displayed in a tooltip.
 
M

mscertified

I solved this one. Here's how I did it in case anyone is interested:

Private Sub lstDelete_Click()
' Can select multiple rows
' Set ControlTipText for last item selected
' Clears ControlTipText if item unselected
Dim strSQL As String, strTip As String
Dim rs As New ADODB.Recordset
If Not Me!lstDelete.Selected(Me!lstDelete.ListIndex + 1) Then
Me!lstDelete.ControlTipText = vbNullString
Set rs = Nothing
Exit Sub
End If
strSQL = "SELECT * FROM tblClient WHERE ID = " & Me!lstDelete.Column(0,
Me!lstDelete.ListIndex + 1)
strTip = vbNullString
rs.Open strSQL, CurrentProject.Connection, adOpenForwardOnly,
adLockReadOnly
If Not rs.EOF Then
strTip = "Name: " & rs.Fields("FN").Value & " " &
rs.Fields("LN").Value & vbCrLf & _
"Tel: " & rs.Fields("Phone").Value & " Email: " &
rs.Fields("Email").Value & vbCrLf
If Nz(rs.Fields("Title").Value, "") <> "" Then
strTip = strTip & "Title: " & rs.Fields("Title").Value & vbCrLf
End If
If Nz(rs.Fields("Org").Value, "") <> "" Then
strTip = strTip & "Org: " & rs.Fields("Org").Value & vbCrLf
End If
If Nz(rs.Fields("Division").Value, "") <> "" Then
strTip = strTip & "Div: " & rs.Fields("Division").Value & vbCrLf
strTip = strTip & "Loc: " & rs.Fields("Location").Value & vbCrLf
End If
strTip = strTip & "Active: " & rs.Fields("ActiveSW").Value & vbCrLf
If Nz(rs.Fields("AddDate").Value, "") <> "" Then
strTip = strTip & "Added: " & rs.Fields("AddDate").Value & vbCrLf
End If
If Nz(rs.Fields("ImpDate").Value, "") <> "" Then
strTip = strTip & "Imported: " & rs.Fields("ImpDate").Value & vbCrLf
End If
End If
rs.Close
Set rs = Nothing
Me!lstDelete.ControlTipText = strTip
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top