PLEASE HELP.....List Box Search Form

  • Thread starter kbrad28 via AccessMonster.com
  • Start date
K

kbrad28 via AccessMonster.com

I have used a sample listbox search form from another database that will
allow you to type and it automatically start listing records that correspond
to that particular letter or letters.

My problem is this...Once I click my record search button the search form
open as it should, but when I type in the text field nothing happens. WHAT AM
I DOING WRONG??? My code for the text field(search field) and for the list
box. Any help will be greatly appreciated.

Private Sub lstResults_DblClick(Cancel As Integer)
On Error GoTo Err_btnSelect_Click

If Not IsNull(Me![lstResults].Column(0)) Then
lngRecipeIDSelect = Me![lstResults].Column(0)
DoCmd.Close
End If
Exit Sub

Err_btnSelect_Click:
MsgBox Err.Number
Exit Sub
End Sub
______________________________________________

Private Sub txtRecipeName_Change()
Dim txtSearchString As Variant
Dim strSQL As String

txtSearchString = Me![txtRecipeName].Text

strSQL = "SELECT DISTINCTROW tblRecipes.RecipeID, tblRecipes.RecipeName,
FROM tblPeople "
strSQL = strSQL & "WHERE ((tblRecipes.RecipeName) Like '" &
txtSearchString & "*')"
strSQL = strSQL & "ORDER BY tblRecipes.RecipeName"

Me!lstResults.RowSource = strSQL
Me!lstResults.Requery
Me!txtRecipeName.SetFocus

End Sub

Kbrad28
 
G

Guest

Try adding a txtSearchString.Recalc or a txtSearchString.Requery before the
statement:

txtSearchString = Me![txtRecipeName].Text

I had a problem once where the textbox wasn't refreshed with the new value
before any code ran.

Ray
 

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