Unbound Text Box

IanT

Registered User.
Local time
Today, 03:42
Joined
Nov 30, 2001
Messages
191
Hi

I have a unbound text box on a form. I am using code to complete a search, each time a letter is input into the text box the code runs. My problem is that I am only able to input one letter in the text box. Has anyone any ideas why this is!

Code I am using:

Function FilterForm()

Dim strFil As String
Dim strNewRecord As String
Dim strSupplier As String
Dim strTp As String

Dim db As DAO.Database
Dim qdf As DAO.QueryDef

Set db = CurrentDb

If Not QueryExists("qryProductSelect") Then
Set qdf = db.CreateQueryDef("qryProductSelect")
Else
Set qdf = db.QueryDefs("qryProductSelect")
End If

If IsNull(Forms!frmCapitalGoods!ctlSubForm.Form!ctlSubForm.Form!txtFind.Value) Then
strFil = " Like '*' "
Else
strFil = " Like '*" & Forms!frmCapitalGoods!ctlSubForm.Form!ctlSubForm.Form!txtFind.Value & "*'"

End If

strNewRecord = "SELECT tblProduct.* " & _
"FROM tblProduct " & _
"WHERE tblProduct.Product_Name" & strFil & ""

qdf.SQL = strNewRecord

DoCmd.Echo False

If Application.SysCmd(acSysCmdGetObjectState, acQuery, "qryProductSelect") = acObjStateOpen Then
DoCmd.Close acQuery, "qryProductSelect"
End If


Forms!frmCapitalGoods!ctlSubForm.Form!ctlSubForm.Form!.RecordSource = "qryProductSelect"

Set qdf = Nothing
Set db = Nothing



End Function
 
What event have you put this into?
 
The idea is when a letter is input the code is called to update the Recordsource of a form to create a search. I have put it in the On Change Event.
 
presumably as soon as you enter 1 character the event is triggered.

Brian
 
So inorder to give me control over when the event ran , so that I can enter more characters and make corrections I would run it from a command button

Brian
 

Users who are viewing this thread

Back
Top Bottom