Open Form based on value from a listbox

rafi

New member
Local time
Today, 02:03
Joined
Jan 13, 2005
Messages
7
Hello !

I am a newbie in access and would appreciate if someone could help me with a delicate problem i have

I have listbox in formA named "Liste1", this listbox contains a departmentvalue (unique) in the first column shown in the listbox.

What i want to do is open a new form (frmStructureDetails) by doubleclicking on the listbox, and i want the new form to load with filter on that department. Btw the departmentvalue is textformatted.

The result i get is a dialoguebox opening and not seeming to recognize which value to use, if i fill inn the value i clicked on the form loads with the correct data.


What am i doing wrong:

Private Sub Liste1_DblClick(Cancel As Integer)
On Error GoTo Err_SearchList_DblClick
Dim db As DAO.Database
Dim rst As DAO.Recordset

DoCmd.OpenForm "frm_StructureDetails", , , "[Department] = " & Me.Liste1


Exit_SearchList_DblClick:
Exit Sub

Err_SearchList_DblClick:
MsgBox Err.Description
Resume Exit_SearchList_DblClick

End Sub
 
Last edited:
im no expert either, but this is what i use and it works great

Set rs = Me.Recordset.Clone
DoCmd.OpenForm "Form Name Here", , , "[ID Here] = " & Me.List Box Name here
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
 

Users who are viewing this thread

Back
Top Bottom