Open form from listbox

Fides

Registered User.
Local time
Today, 03:14
Joined
Jul 17, 2012
Messages
23
Hello everyone.

I have a form with 2 listboxes, 1 listbox filters the other. Now I want to add a doubleclick event on the filtered listbox that opens a form with the selected record in it. I currently have the following code:
Code:
Private Sub lstNamen_DblClick(Cancel As Integer)

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmBas Registratie"
    
    stLinkCriteria = "tblOverige.ID=" & "'" & Me!lstNamen.Column(5) & "'"
    
    DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

But with this I get a type mismatch. I have selected the right column (5).

Thanks in advance for all your help.
 
Welcome to the forum.

If as I suspect your field tblOverige.ID is a number then your code need to look like;

Code:
Private Sub lstNamen_DblClick(Cancel As Integer)

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmBas Registratie"
    
    stLinkCriteria = "tblOverige.ID= " & Me!lstNamen.Column(5) 
    
    DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub
 
Thanks, that did it.
I'm really a noob in coding. Hahaha. I'll post more questions that look 'stupid' for the code wizards. Hahaha :)
 

Users who are viewing this thread

Back
Top Bottom