PDA

View Full Version : [SOLVED:] Double click from list box to selected record



daSpud
04-19-2018, 01:51 PM
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

OBP
04-20-2018, 01:02 AM
Try
DoCmd.OpenForm DocName, , , "[Lot_No] = " &
[List14]
or
DoCmd.OpenForm DocName, , , "[Lot_No] = '" &
[List14] & "' "

daSpud
04-20-2018, 08:24 AM
Try

DoCmd.OpenForm DocName, , , "[Lot_No] = '" &
[List14] & "' "

That did the trick. So List14 had to be surrounded by single quotes.

THANK YOU