List box

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?
 
K

Ken Sheridan

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
 

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