Consulting

Results 1 to 3 of 3

Thread: Double click from list box to selected record

  1. #1
    VBAX Regular
    Joined
    Apr 2018
    Posts
    10
    Location

    Double click from list box to selected record

    I have a List box
    [List14] that shows all the lots with Lot_No, homeowner name and email.

    I want to double click on a line and open a form with the home record that was double clicked on.

    I have code in the Double Click event, but can't quite get the form open with the record.

    The msgbox displays 0011 (the correct record) but it asks me for the value of the parameter.
    If I type in 0011 I get the new form with the right Lot_No.

    If I change the parameter to '0011' in place of
    [List14] it goes to that Lot_No no matter where I double click. I would expect this since I hard coded the Lot_No. I don't understand why using
    [List14] doesn't do a similar thing since the value of
    [List14] is 0011 when I click on that record.

    hmmm.. seems use of square brackets puts that to the front of the line. Is there an escape char for that?

    Thank you for any help.

    Private Sub List14_DblClick(Cancel As Integer)
    On Error GoTo Err_List14_DblClick
    
    
        Dim DocName As String
        Dim LinkCriteria As String
    
    
        MsgBox 
    [List14]
    
    
        DocName = "frmHomeOwner"
        DoCmd.OpenForm DocName, , , "[Lot_No] = 
    [List14]" 
    
    
    Exit_List14_DblClick:
        Exit Sub
    
    
    Err_List14_DblClick:
        MsgBox Error$
        Resume Exit_List14_DblClick
    
    
    End Sub
    Last edited by daSpud; 04-19-2018 at 01:55 PM. Reason: lines formatted strangely

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Try
    DoCmd.OpenForm DocName, , , "[Lot_No] = " &
    [List14]
    or
    DoCmd.OpenForm DocName, , , "[Lot_No] = '" &
    [List14] & "' "

  3. #3
    VBAX Regular
    Joined
    Apr 2018
    Posts
    10
    Location

    Thumbs up

    Quote Originally Posted by OBP View Post
    Try

    DoCmd.OpenForm DocName, , , "[Lot_No] = '" &
    [List14] & "' "
    That did the trick. So List14 had to be surrounded by single quotes.

    THANK YOU

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •