Luddite Lad
Registered User.
- Local time
- Tomorrow, 06:32
- Joined
- Aug 23, 2005
- Messages
- 177
I have combined the list box sort function discussed here with the Search tool discussed here.
No problems thus far
I'm using the following piece of code that activates on the OnChange Event of the text box that is feeding the search query. The code ensures that the first row in the list box is always the row that is selected in the list box, as this feeds a number of controls which show details for that row.
This all works fine until the list box is re sorted. So what I would like to do is make the code more flexible and able to deal with changes in the sort criteria.
I figure that I need to make a change here;
However I've been unable to figure out the correct syntax for doing this and am even starting to wonder if that is in fact the correct approach.
Any suggestions gratefully received.
No problems thus far
I'm using the following piece of code that activates on the OnChange Event of the text box that is feeding the search query. The code ensures that the first row in the list box is always the row that is selected in the list box, as this feeds a number of controls which show details for that row.
Code:
Dim vSearchString As String, SortOrd As String
SortOrd = Me.Text99.Value
vSearchString = Text0.Text
Text5.Value = vSearchString
Me.List2.Requery
If Len(Me.Text5) <> 0 And InStr(Len(Text5), Text5, " ", vbTextCompare) Then
Exit Sub
End If
If Me.List2.ListCount < 2 Then
MsgBox "No Result for current search"
Else
Me.Bookmark = Me.RecordsetClone.Bookmark
Me.List2 = Me.List2.ItemData(1)
DoCmd.Requery
Me.RecordsetClone.findfirst "[WineID]=" & Me![List2]
End If
If Len(Me.Text0) <> 0 Then
Me.Text0.SelStart = Len(Me.Text0)
End If
This all works fine until the list box is re sorted. So what I would like to do is make the code more flexible and able to deal with changes in the sort criteria.
I figure that I need to make a change here;
Code:
Me.RecordsetClone.findfirst "[WineID]=" & Me![List2]
However I've been unable to figure out the correct syntax for doing this and am even starting to wonder if that is in fact the correct approach.
Any suggestions gratefully received.