Stephen Lebans alpha search w/listbox

  • Thread starter Thread starter JIM
  • Start date Start date
J

JIM

I'd like to use Stephen Lebans alpha search to load a list box. I have his
search working perfectly and it returns the alpha character in strTemp that
user picks. In Stephen's example he is loading a textbox. I would like to
load a listbox starting with alpha character that user has pressed. Here's
my code:

Private Sub LblAlpha_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)
If Len(strTemp) & vbNullString = 0 Then
Me.FilterOn = False
Else
Me.Filter = "lboCustomer.CustomerName LIKE " & Chr(34) & strTemp & "*" &
Chr(34)
Me.FilterOn = True
End If

DoEvents
End Sub

I don't know the syntax to apply to a listbox. strTemp holds the alpha
character that I'd like to start loading the Customer table into listbox.
I'm using a query as a source.
Any help appreciated.
 
Also when I run this code I get the message "Enter Parameter Value"
"lboCustomer.CustomerName".
 
I'm making progress with my form and here is latest code:

Private Sub LblAlpha_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Dim strSQL As String

If Len(strTemp) & vbNullString = 0 Then
' Me.FilterOn = False
Else
MsgBox "strTemp = " & strTemp
strSQL = "SELECT DISTINCTROW tblCustomer.CustomerName,
tblCustomer.BillingAddress1, FROM tblCustomer WHERE
((tblCustomer.CustomerName) LIKE '" & strTemp & "*') ORDER BY
tlbCustomer.CustomerName"
Me!lboCustomer.RowSource = strSQL
Me!lboCustomer.Requery
Me!lboCustomer.SetFocus

End If

DoEvents
End Sub

strTemp holds the alpha character I want to filter the list box by. Is
there something wrong with the SQL? Everything works but the requery.
TIA
 
Back
Top