List box

  • Thread starter Thread starter Pass-the-reality
  • Start date Start date
P

Pass-the-reality

In my list box, I want to double click (or roll mouse over) items in the list
box and have a definition for the selected item to display. If I just click
one time, I do not want the definition to display. What coding would I need?
 
Firstly you'd have to design a form, in single form view, based on a table of
definitions whose primary key column contains the same values as the items in
your list box (so a query on the same table can be used for the list box's
RowSource of course). Set the properties of the form so it appears as a
simple dialogue form, without records selectors, navigation buttons etc.
Then in the DblClick event procedure of the list box put code along these
lines:

On Error GoTo Err_Handler

Dim ctrl as Control

Set ctrl = Me.ActiveControl

If Not IsNull(ctrl) Then
DoCmd.OpenForm "YourDialogueForm", _
WhereCondition:="YourItem = """ & ctrl & """", _
WindowMode:=acDialog
End If

Exit_Here:
Exit Sub

Err_Handler:
MsgBox Err.Description & " (" & Err.Number & ")", vbExclamation, "Error"
Resume Exit_Here

This assumes that the items in the list are text, hence the quotes
characters around the value.

Ken Sheridan
Stafford, England
 
Back
Top