List box

Haynesey

Registered User.
Local time
Today, 22:57
Joined
Dec 19, 2001
Messages
190
I have used an unbound list box related to a query to show all related to records logged for a particular person. This works great but is there anyway of being able to double click on a record in the list and open the full details?

Thanks in advance
Lee
 
Private Sub lstFound_DblClick(Cancel As Integer)
On Error GoTo Err_lstFound_DblClick

Dim strFormName As String

strFormName = "FormName"

DoCmd.OpenForm strFormName, , , "[KeyID] = " & Me!lstFound

DoCmd.Close acForm, Me.Name

Exit_lstFound_DblClick:
Exit Sub

Err_lstFound_DblClick:
MsgBox Err.Description
Resume Exit_lstFound_DblClick

End Sub
 
HI Haynesey,

there sure is! In VBA, select your listboxes Double-Click event (Just in case: (1) open the form in design view - select view - select Code (2) there will be two drop-down lists at the top of your screen - select the name of your list box, then on the second drop down list, select "DblClick").

Now type in this sentence (replacing names where necessary):
DoCmd.OpenForm "frmDetails", acNormal, , ("ReportID = " & ListReports.Column(0))

The whole statement is like a query saying OPEN frmDetails in Normal view WHERE ReportID is equal to whatever is in the first column of the listbox called ListReports.

Remember to change the form name and search variable (ReportID).

If you still have trouble, reply to this post telling us exactly what is in your listbox.

Good luck!

-Sean

D-oh! Rich beat me!!
 

Users who are viewing this thread

Back
Top Bottom