Avatar of John Sheehy
John Sheehy
Flag for United States of America asked on

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
DatabasesMicrosoft AccessVBA

Avatar of undefined
Last Comment
John Sheehy

8/22/2022 - Mon
Fabrice Lambert

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 Sheehy

ASKER
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
ASKER CERTIFIED SOLUTION
John Sheehy

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
John Sheehy

ASKER
I was able to figure out before an expert commented on it
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23