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