How to DoubleClick Listbox showing results from a search in a query

wrweaver

Registered User.
Local time
Today, 12:05
Joined
Feb 26, 2013
Messages
75
I have a listbox displaying results from a string search in a text box of a query. Im trying to build an event where the user can doubleclick on the selected result and it will take them to that record. This is the code I have but it won't take me to the selected record in the form. It takes me to a new blank record in that form. The fields in the query are on the attached photo.

Private Sub SearchResults_DblClick(Cancel As Integer)

DoCmd.OpenForm "WorkOrderF", , , WorkOrderID = " & SearchResults"


End Sub

Private Sub WorkOrderSearch_Change()
Dim vSearchString As String
vSearchString = WorkOrderSearch.Text
SrchText.Value = vSearchString
Me.SearchResults.Requery

If Len(Me.SrchText) <> 0 And InStr(Len(SrchText), SrchText, " ", vbTextCompare) Then
Exit Sub
End If
Me.SearchResults = Me.SearchResults.ItemData(1)
Me.SearchResults.SetFocus
DoCmd.Requery
Me.WorkOrderSearch.SetFocus
If Not IsNull(Len(Me.WorkOrderSearch)) Then
Me.WorkOrderSearch.SelStart = Len(Me.WorkOrderSearch)
End If
End Sub


All help would be greatly appreciated! Thank you!
 

Attachments

  • 20130226_125733.jpg
    20130226_125733.jpg
    99.3 KB · Views: 119
You were right. It was me.searchresults. Thanks Paul!!!!
 
No problem! Your quotes were also out of whack.
 

Users who are viewing this thread

Back
Top Bottom