Using textbox in form as wildcard function search

  • Thread starter Thread starter \NG Tian via AccessMonster.com\
  • Start date Start date
N

\NG Tian via AccessMonster.com\

hi ppl

I had a minor problem how to deal the wildcard function as "like"
My requirement is when i input any ABC in textbox{txtSearch}, then i press a
button to return all the records with first A. for etc, i input Ba in textbox
and press button to return all the records with first Ba, etc Barcon, Bail,
Bapalia, and go on.

my current simple code does not work, because when i input A, it return one
result although i have thousand of words starting with A.

Are u able to help ?


The code is like that,

Option Compare Database
Option Explicit
Private Sub cmdSearch_Click()
On Error GoTo Err_cmdSearch_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Search Engine"

stLinkCriteria = "[Project] like " & Chr$(34) & Me![txtSearch] & "*" &
Chr$(34)
DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_cmdSearch_Click:
Exit Sub

Err_cmdSearch_Click:
MsgBox Err.Description
Resume Exit_cmdSearch_Click

End Sub
 
I don't see anything obviously wrong with what you've got.

Try putting a Debug.Print stLinkCriteria after you've set stLinkCriteria to
make sure it's getting set correctly.
 
Back
Top