Stephen Lebans alpha search w/listbox

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.
 
J

JIM

Also when I run this code I get the message "Enter Parameter Value"
"lboCustomer.CustomerName".
 
J

JIM

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top