Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Stephen Lebans alpha search w/listbox

Geek News

Stephen Lebans alpha search w/listbox
JIM 11/23/2008 1:30:01 PM
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.


RE: Stephen Lebans alpha search w/listbox
JIM 11/23/2008 1:35:00 PM
Also when I run this code I get the message "Enter Parameter Value"
"lboCustomer.CustomerName".

"JIM" wrote:

[Quoted Text]
> 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.
>
>
RE: Stephen Lebans alpha search w/listbox
JIM 11/26/2008 12:47:01 AM
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


"JIM" wrote:

[Quoted Text]
> Also when I run this code I get the message "Enter Parameter Value"
> "lboCustomer.CustomerName".
>
> "JIM" wrote:
>
> > 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.
> >
> >

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net