We help IT Professionals succeed at work.

Opening a form based on a record selected in a list box

So now that I have the list box working correctly I am needing the ability to select a record in the list box, double click it and a form displaying everything associated with the record is displayed.  

I have a unique ID; Hardware_ID and the form I need it to open is frm_Inventory
The name of the list box is HWB_LIST

Thanks
John
Comment
Watch Question

Fabrice LambertConsulting
Distinguished Expert 2017

Commented:
Hi,

Use the double click event of your list box:
Private Sub HWB_LIST_DblClick(Cancel As Integer)
    Select Case HWB_LIST.Value
        '// ect ect ...
    End Select
End Sub

Open in new window

John SheehySystem Security Manager

Author

Commented:
I don't know how to tell the double click event to open the correct record.  Maybe something like this?

stLinkCriteria = "[Hardware_ID]=" & "'" & Me.HWB_LIST.Hardware_ID & "'"
stDOCName = "frm_Inventory"

        DoCmd.OpenForm stDOCName, , , stLinkCriteria

    End If

John
System Security Manager
Commented:
So I figured it out.  The solution is:

stLinkCriteria = "[Hardware_ID]=" & Me.HWB_LIST.Value
stDOCName = "frm_Inventory"

        DoCmd.OpenForm stDOCName, , , stLinkCriteria

John
John SheehySystem Security Manager

Author

Commented:
I was able to figure out before an expert commented on it